﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using BLL;
using Model;
using gfLibrary;
using System.Drawing;
using IYAKASAPortal.Services;
using System.Data;
using System.Xml.Linq;
using System.IO;
using System.Xml;
using System.Web.UI.HtmlControls;
using System.Web.Services;
using DBUtility;
using System.Configuration;
using System.Reflection;

namespace IYAKASAPortal.Login
{
    public partial class LoginAJ : System.Web.UI.Page
    {
        private UserInfo userInfo { get; set; }
        private static List<ListItem> lstItems { get; set; }
        private static List<ListItem> lstItemsGC { get; set; }
        protected void Page_Load(object sender, EventArgs e)
        {
            if (Session["UserName"] != null && Session["UserName"].ToString() != "")
            {
                string userName = Session["UserName"].ToString();
                userInfo = IYAKASAPortal.Services.UserAuthority.GetUserAuthority(userName);
            }
            else
            {
                gfJs.RunFunction(this.Page, "parent.window.location = '../logout.aspx';");
            }

            if (!IsPostBack)
            {
                BindData();
            }
        }

        private void BindData()
        {
            lstItems = new List<ListItem>();
            lstItemsGC = new List<ListItem>();
            CONST_DEFINE_BLL bll = new CONST_DEFINE_BLL();
            var def = bll.GetModelList("CON_CHNAME='JYLB' and CON_VTYPE='2' order by CON_ORDER asc");

            ListItem item;
            foreach (var v in def)
            {
                item = new ListItem();
                item.Text = v.CON_CON;
                item.Value = v.CON_CODE;
                drpTestType.Items.Add(item);
                drpTestTypeGC.Items.Add(item);
            }

            var clzl = bll.GetModelList("CON_CHNAME='CLZL' and SUBSTRING(CON_CODE,1,1)<>'B' order by CON_ORDER asc");
            foreach (var v in clzl)
            {
                item = new ListItem();
                item.Text = v.CON_CON;
                item.Value = v.CON_CODE;
                drpCLZL.Items.Add(item);
            }

            var gcclzl = bll.GetModelList("CON_CHNAME='CLZL' and SUBSTRING(CON_CODE,1,1)='B' order by CON_ORDER asc");
            foreach (var v in gcclzl)
            {
                item = new ListItem();
                item.Text = v.CON_CON;
                item.Value = v.CON_CODE;
                drpCLZLGC.Items.Add(item);
            }

            var hpzl = bll.GetModelList("CON_CHNAME='HPZL' and CON_CODE<>15 order by CON_ORDER asc");
            foreach (var v in hpzl)
            {
                item = new ListItem();
                item.Text = v.CON_CON;
                item.Value = v.CON_CODE;
                drpHPZL.Items.Add(item);
            }
            drpHPZLGC.Items.Add(new ListItem() { Text = "挂车", Value = "15" });

            var syxz = bll.GetModelList("CON_CHNAME='SYXZ' order by CON_ORDER asc");
            foreach (var v in syxz)
            {
                item = new ListItem();
                item.Text = v.CON_CON;
                item.Value = v.CON_CODE;
                drpSYXZ.Items.Add(item);
                drpSYXZGC.Items.Add(item);
            }

            var zxzxjxs = bll.GetModelList("CON_CHNAME='ZXZXJXS' order by CON_ORDER asc");
            foreach (var v in zxzxjxs)
            {
                item = new ListItem();
                item.Text = v.CON_CON;
                item.Value = v.CON_CODE;
                drpZXZXJXS.Items.Add(item);
            }

            var zxzlx = bll.GetModelList("CON_CHNAME='ZXZLX' order by CON_ORDER asc");
            foreach (var v in zxzlx)
            {
                item = new ListItem();
                item.Text = v.CON_CON;
                item.Value = v.CON_CODE;
                drpZXZLX.Items.Add(item);
            }

            var qzdz = bll.GetModelList("CON_CHNAME='QZDZ' order by CON_ORDER asc");
            foreach (var v in qzdz)
            {
                item = new ListItem();
                item.Text = v.CON_CON;
                item.Value = v.CON_CODE;
                drpQZDZ.Items.Add(item);
            }

            var yggsnfkt = bll.GetModelList("CON_CHNAME='YGGSNFKT' order by CON_ORDER asc");
            foreach (var v in yggsnfkt)
            {
                item = new ListItem();
                item.Text = v.CON_CON;
                item.Value = v.CON_CODE;
                drpYGGSNFKT.Items.Add(item);
            }

            var rllb = bll.GetModelList("CON_CHNAME='RLLB' order by CON_ORDER asc");
            foreach (var v in rllb)
            {
                item = new ListItem();
                item.Text = v.CON_CON;
                item.Value = v.CON_CODE;
                drpRLLB.Items.Add(item);
            }

            var lwcxwzjl = bll.GetModelList("CON_CHNAME='LWCXWZJL' order by CON_ORDER asc");
            foreach (var v in lwcxwzjl)
            {
                item = new ListItem();
                item.Text = v.CON_CON;
                item.Value = v.CON_CODE;
                drpLWCXWZJL.Items.Add(item);
                drpLWCXGC.Items.Add(item);
            }

            var jyxm = bll.GetModelList("CON_CHNAME='JYXM' and CON_JCTYPE like '%01,%' order by CON_ORDER asc");
            foreach (var v in jyxm)
            {
                item = new ListItem();
                item.Text = v.CON_CON;
                item.Value = v.CON_CODE;
                lstItems.Add(item);
            }

            var jyxmGC = bll.GetModelList("CON_CHNAME='JYXM' and CON_JCTYPE like '%02,%' order by CON_ORDER asc");
            foreach (var v in jyxmGC)
            {
                item = new ListItem();
                item.Text = v.CON_CON;
                item.Value = v.CON_CODE;
                lstItemsGC.Add(item);
            }

            for (int i = 2; i < 7; i++)
            {
                item = new ListItem();
                item.Text = i.ToString();
                item.Value = i.ToString();
                drpZZS.Items.Add(item);
                drpZZSGC.Items.Add(item);
            }

            //绑定模板
            CONST_DEFINE_WEB_BLL cdw_bll = new CONST_DEFINE_WEB_BLL();
            var jyxmmb = cdw_bll.GetModelList("CategoryId='10'");
            foreach (var j in jyxmmb)
            {
                item = new ListItem();
                item.Text = j.Name;
                item.Value = j.ValueOfName;
                rbtnTemplate.Items.Add(item);
            }

            //绑定号码开头
            CONST_DEFINE_WEB_CATEGORY_BLL category_bll = new CONST_DEFINE_WEB_CATEGORY_BLL();
            var hphmStart = category_bll.GetModel(8);
            txtHPHMStart.Text = hphmStart.CategoryName;
            txtHPHMStartGC.Text = hphmStart.CategoryName;

            var keyValue = category_bll.GetModel(9);
            hidKeyValue.Value = keyValue.CategoryName;

            //绑定驻车轴位置
            LoginHelper.BindZCZWZ(Convert.ToInt32(drpZZS.SelectedValue), chkZCZWZ, chkQDZWZ);

            //绑定挂车驻车轴位置
            LoginHelper.BindZCZWZ(Convert.ToInt32(drpZZSGC.SelectedValue), chkZCZWZGC);

            //绑定检测项目
            ReBindJCXM();

            //绑定挂车检测项目
            ReBindJCXMGC();

            chkQCLC_CheckedChanged(null, null);
        }

        protected void chkAll_CheckedChanged(object sender, EventArgs e)
        {
            LoginHelper.CheckAll(chkJYXM, chkAll.Checked);
        }

        protected void btnSave_Click(object sender, EventArgs e)
        {
            //安检检验登录
            string strJYLB = drpTestType.SelectedValue.Trim() + ",";
            string strHPHM = txtHPHMStart.Text.Trim().ToUpper() + txtHPHM.Text.Trim().ToUpper();
            string strHPHM_H = txtHPHMStart.Text.Trim().ToUpper();
            string strHPHM_C = txtHPHM.Text.Trim().ToUpper();
            string strHPZL = drpHPZL.SelectedValue.Trim();
            string strVIN = txtVIN.Text.Trim().ToUpper();
            string strSYR = txtSYR.Text.Trim();
            string strAddress = txtAddress.Text.Trim();
            string strPP = txtPP.Text.Trim();
            string strXH = txtXH.Text.Trim().ToUpper();
            string strFDJHM = txtFDJNumber.Text.Trim().ToUpper();
            string strCCRQ = txtCCRQ.Text.Trim();
            string strCSDJRQ = txtCSDJRQ.Text.Trim();
            string strHZRS = txtHZRS.Text.Trim();
            string strZZL = txtZZL.Text.Trim();
            string strZBZL = txtZBZL.Text.Trim();
            string strWKCCC = txtWKCCC.Text.Trim();
            string strWKCCK = txtWKCCK.Text.Trim();
            string strWKCCG = txtWKCCG.Text.Trim();
            string strHDZZL = txtHDZZL.Text.Trim();
            string strZGSJCS = txtZGSJCS.Text.Trim();
            string strLJXSLC = txtLJXSLC.Text.Trim();

            if (string.IsNullOrEmpty(strHPHM_H))
            {
                gfAjaxJs.SetAlertMsg(this.UpdatePanel1, "号牌号码开头不能为空！");
                txtHPHMStart.Focus();
                txtHPHMStart.BackColor = Color.Yellow;
                return;
            }
            else
            {
                txtHPHMStart.BackColor = Color.White;
            }

            if (string.IsNullOrEmpty(strHPHM_C))
            {
                gfAjaxJs.SetAlertMsg(this.UpdatePanel1, "号牌号码不能为空！");
                txtHPHM.Focus();
                txtHPHM.BackColor = Color.Yellow;
                return;
            }
            else
            {
                txtHPHM.BackColor = Color.White;
            }

            //VIN
            if (string.IsNullOrEmpty(strVIN) == false)
            {
                txtVIN.BackColor = Color.White;
            }

            //所有人
            if (string.IsNullOrEmpty(strSYR) == false)
            {
                txtSYR.BackColor = Color.White;
            }

            //住址
            if (string.IsNullOrEmpty(strAddress) == false)
            {
                txtAddress.BackColor = Color.White;
            }

            //品牌
            if (string.IsNullOrEmpty(strPP) ==false)
            {
                txtPP.BackColor = Color.White;
            }

            //型号
            if (string.IsNullOrEmpty(strXH) == false)
            {
                txtXH.BackColor = Color.White;
            }

            //发动机/电动机号码
            if (string.IsNullOrEmpty(strFDJHM) == false)
            {
                txtFDJNumber.BackColor = Color.White;
            }

            //出厂日期
            if (!string.IsNullOrEmpty(strCCRQ))
            {
                if (gfValidate.Is_DateTime(strCCRQ) == false)
                {
                    gfAjaxJs.SetAlertMsg(this.UpdatePanel1, "出厂日期不是有效的日期格式！");
                    txtCCRQ.BackColor = Color.Yellow;
                    return;
                }
                else
                {
                    txtCCRQ.BackColor = Color.White;
                }
            }

            //初始登记日期
            if (!string.IsNullOrEmpty(strCSDJRQ))
            {
                if (gfValidate.Is_DateTime(strCSDJRQ) == false)
                {
                    gfAjaxJs.SetAlertMsg(this.UpdatePanel1, "初始登记日期不是日期格式！");
                    txtCSDJRQ.BackColor = Color.Yellow;
                    return;
                }
                else
                {
                    txtCSDJRQ.BackColor = Color.White;
                }
            }

            //核载人数
            if (string.IsNullOrEmpty(strHZRS) == false)
            {
                if (gfValidate.Is_Integer(strHZRS) == false)
                {
                    gfAjaxJs.SetAlertMsg(this.UpdatePanel1, "核载人数不是数字格式！");
                    txtHZRS.BackColor = Color.Yellow;
                }
                else
                {
                    txtHZRS.BackColor = Color.White;
                }
                
            }

            //总质量
            if (string.IsNullOrEmpty(strZZL) == false)
            {
                if (!gfValidate.Is_Integer(strZZL))
                {
                    gfAjaxJs.SetAlertMsg(this.UpdatePanel1, "总质量只能为整数！");
                    txtZZL.BackColor = Color.Yellow;
                    return;
                }
                else
                {
                    txtZZL.BackColor = Color.White;
                }
            }

            //整备质量
            if (string.IsNullOrEmpty(strZBZL) == false)
            {
                if (!gfValidate.Is_Integer(strZBZL))
                {
                    gfAjaxJs.SetAlertMsg(this.UpdatePanel1, "整备质量只能为整数！");
                    txtZBZL.BackColor = Color.Yellow;
                }
                else
                {
                    txtZBZL.BackColor = Color.White;
                }
            }

            //核定载质量
            if (!string.IsNullOrEmpty(strHDZZL) && !gfValidate.Is_Integer(strHDZZL))
            {
                gfAjaxJs.SetAlertMsg(this.UpdatePanel1, "核定载质量只能为整数！");
                txtHDZZL.BackColor = Color.Yellow;
            }
            else
            {
                txtHDZZL.BackColor = Color.White;
            }

            //外廓尺寸长
            if (string.IsNullOrEmpty(strWKCCC) == false)
            {
                if (!gfValidate.Is_Integer(strWKCCC))
                {
                    gfAjaxJs.SetAlertMsg(this.UpdatePanel1, "外廓尺寸长只能为整数！");
                    txtWKCCC.BackColor = Color.Yellow;
                }
                else
                {
                    txtWKCCC.BackColor = Color.White;
                }
            }

            //外廓尺寸宽
            if (string.IsNullOrEmpty(strWKCCK) == false)
            {
                if (!gfValidate.Is_Integer(strWKCCK))
                {
                    gfAjaxJs.SetAlertMsg(this.UpdatePanel1, "外廓尺寸宽只能为整数！");
                    txtWKCCK.BackColor = Color.Yellow;
                }
                else
                {
                    txtWKCCK.BackColor = Color.White;
                }
            }

            if (string.IsNullOrEmpty(strWKCCG) == false)
            {
                if (!gfValidate.Is_Integer(strWKCCG))
                {
                    gfAjaxJs.SetAlertMsg(this.UpdatePanel1, "外廓尺寸高只能为整数！");
                    txtWKCCG.BackColor = Color.Yellow;
                }
                else
                {
                    txtWKCCG.BackColor = Color.White;
                }
            }

            if (string.IsNullOrEmpty(strZGSJCS) == false)
            {
                if (!gfValidate.Is_Integer(strZGSJCS))
                {
                    gfAjaxJs.SetAlertMsg(this.UpdatePanel1, "最高设计车速只能为整数！");
                    txtZGSJCS.BackColor = Color.Yellow;
                }
                else
                {
                    txtZGSJCS.BackColor = Color.White;
                }
            }

            //累计行驶里程
            if (string.IsNullOrEmpty(strLJXSLC) == false)
            {
                if (!gfLibrary.gfValidate.Is_Float(strLJXSLC))
                {
                    gfAjaxJs.SetAlertMsg(this.UpdatePanel1, "[累计行驶里程]不是有效的数字格式！");
                    txtLJXSLC.BackColor = Color.Yellow;
                }
                else
                {
                    txtLJXSLC.BackColor = Color.White;
                }
            }
           
            //驻车轴位置
            string strZCZWZ = "";
            for (int i = 0; i < chkZCZWZ.Items.Count; i++)
            {
                if (chkZCZWZ.Items[i].Selected)
                {
                    strZCZWZ += chkZCZWZ.Items[i].Value + ",";
                }
            }

            //驱动轴位置
            string strQDZWZ = "";
            for (int i = 0; i < chkQDZWZ.Items.Count; i++)
            {
                if (chkQDZWZ.Items[i].Selected)
                {
                    strQDZWZ += chkQDZWZ.Items[i].Value + ",";
                }
            }


            //bool b = false;
            //for (int i = 0; i < chkJYXM.Items.Count; i++)
            //{
            //    if (chkJYXM.Items[i].Selected)
            //    {
            //        b = true;
            //        break;
            //    }
            //}

            //if (b == false)
            //{
            //    gfAjaxJs.SetAlertMsg(this.UpdatePanel1, "请选择检验项目！");
            //    return;
            //}

            string strJYXM = "";
            for (int i = 0; i < chkJYXM.Items.Count; i++)
            {
                if (chkJYXM.Items[i].Selected)
                {
                    strJYXM += chkJYXM.Items[i].Value + ",";
                }
            }

            string strSFSQCLC = chkQCLC.Checked ? "1" : "0";

            string strVEHICLEID = strHPZL + strHPHM;

            LOGIN_VEHICLE_INFO info = new LOGIN_VEHICLE_INFO();
            info.VEHICLEID = strVEHICLEID;
            info.HPHM = strHPHM;
            info.CLZL = drpCLZL.SelectedItem.Text;
            info.CLZLDH = drpCLZL.SelectedItem.Value;
            info.HPZL = drpHPZL.SelectedItem.Text;
            info.HPZLDH = strHPZL;
            info.VIN = strVIN;
            info.JYLB = drpTestType.SelectedItem.Text;
            info.JYLBDH = strJYLB;
            info.FDJH = strFDJHM;
            info.PP = strPP;
            info.XH = strXH;
            info.PPXH = strPP + strXH;
            info.ZCZWZ = strZCZWZ;
            info.QZDZ = drpQZDZ.SelectedItem.Text;
            info.QZDZDH = drpQZDZ.SelectedItem.Value;
            info.YGGSNFKT = drpYGGSNFKT.SelectedItem.Text;
            info.YGGSNFKTDH = drpYGGSNFKT.SelectedItem.Value;
            info.RLLB = drpRLLB.SelectedItem.Text;
            info.RLLBDH = drpRLLB.SelectedItem.Value;
            info.CCDJRQ = strCSDJRQ;
            info.CCRQ = strCSDJRQ;
            info.ZBZL = strZBZL;
            info.ZZL = strZZL;
            info.CYS = strHZRS;
            info.ZXZXJXS = drpZXZXJXS.SelectedItem.Text;
            info.ZXZXJXSDH = drpZXZXJXS.SelectedItem.Value;
            info.ZXZLX = drpZXZLX.SelectedItem.Text;
            info.ZXZLXDH = drpZXZLX.SelectedItem.Value;
            info.ZGSJCS = strZGSJCS;
            info.SYR = strSYR;
            info.LXDZ = strAddress;
            info.SYXZ = drpSYXZ.SelectedItem.Text;
            info.SYXZDH = drpSYXZ.SelectedItem.Value;
            info.HDZH = strHDZZL;
            info.JYXM_LW = strJYXM;
            info.JYXM = strJYXM;
            info.CSC = strWKCCC;
            info.CSK = strWKCCK;
            info.CSG = strWKCCG;
            info.DLY = userInfo.UserName;
            info.ZZS = drpZZS.SelectedValue;
            info.QDZWZ = strQDZWZ;
            info.LWCXWZJLDH = drpLWCXWZJL.SelectedItem.Value;
            info.LWCXWZJL = drpLWCXWZJL.SelectedItem.Text;
            info.CCRQ = strCCRQ;
            info.SFSQCLC = strSFSQCLC;
            info.LJXSLC = strLJXSLC;

            LOGIN_VEHICLE_INFO_BLL bll = new LOGIN_VEHICLE_INFO_BLL();

            if (string.IsNullOrEmpty(userInfo.UserName))
            {
                gfAjaxJs.SetAlertMsg(this.UpdatePanel1, "当前没有授权,请退出系统重新登录！");
                return;
            }

            bool bOnGoing = LoginHelper.GetVehicleStatus(strVEHICLEID);
            if (bOnGoing)
            {
                gfAjaxJs.SetAlertMsg(this.UpdatePanel1, "车辆【" + strVEHICLEID + "】正在检测，不能保存当前信息！");
                return;
            }

            var vInfo = LoginHelper.GetLoginInfo(strHPHM, strHPZL);

            if (vInfo == null)
            {
                if (bll.Insert(info) == true)
                {
                    hidID.Value = LoginHelper.GetLoginInfo(strHPHM, strHPZL).ID.ToString();
                    LoginHelper.SavePPXHAndFDJXH(info);
                    gfAjaxJs.SetAlertMsg(this.UpdatePanel1, "车牌号码【" + strHPHM + "】保存成功！");
                    btnSend.Enabled = true;
                    btnSend.CssClass = "btnSendEnabled";
                }
                else
                {
                    gfAjaxJs.SetAlertMsg(this.UpdatePanel1, "车牌号码【" + strHPHM + "】保存失败！");
                    return;
                }
            }
            else
            {
                if (bll.Update(info, vInfo.ID) == true)
                {
                    hidID.Value = vInfo.ID.ToString();
                    LoginHelper.SavePPXHAndFDJXH(info);
                    gfAjaxJs.SetAlertMsg(this.UpdatePanel1, "车牌号码【" + strHPHM + "】更新成功！");
                    btnSend.Enabled = true;
                    btnSend.CssClass = "btnSendEnabled";
                }
                else
                {
                    gfAjaxJs.SetAlertMsg(this.UpdatePanel1, "车牌号码【" + strHPHM + "】更新失败！");
                    return;
                }
            }
        }

        private void ResetAll()
        {
            drpZZS.SelectedValue = "2";
            drpZZS_SelectedIndexChanged(null, null);

            List<LoginHelper.ControlNames> lstCtl = new List<LoginHelper.ControlNames>();
            List<Control> lstControls = new List<Control>();

            lstCtl.Add(new LoginHelper.ControlNames(drpTestType.ID,""));
            lstControls.Add(drpTestType);

            lstCtl.Add(new LoginHelper.ControlNames(drpHPZL.ID, ""));
            lstControls.Add(drpHPZL);

            lstCtl.Add(new LoginHelper.ControlNames(drpLWCXWZJL.ID, ""));
            lstControls.Add(drpLWCXWZJL);

            lstCtl.Add(new LoginHelper.ControlNames(drpQZDZ.ID, ""));
            lstControls.Add(drpQZDZ);

            lstCtl.Add(new LoginHelper.ControlNames(drpRLLB.ID, ""));
            lstControls.Add(drpRLLB);

            lstCtl.Add(new LoginHelper.ControlNames(txtCCRQ.ID, ""));
            lstControls.Add(txtCCRQ);

            lstCtl.Add(new LoginHelper.ControlNames(drpSYXZ.ID, ""));
            lstControls.Add(drpSYXZ);

            lstCtl.Add(new LoginHelper.ControlNames(drpYGGSNFKT.ID, ""));
            lstControls.Add(drpYGGSNFKT);

            lstCtl.Add(new LoginHelper.ControlNames(chkZCZWZ.ID, "2,"));
            lstControls.Add(chkZCZWZ);

            lstCtl.Add(new LoginHelper.ControlNames(chkQDZWZ.ID, "2,"));
            lstControls.Add(chkQDZWZ);

            lstCtl.Add(new LoginHelper.ControlNames(drpZXZLX.ID, ""));
            lstControls.Add(drpZXZLX);

            lstCtl.Add(new LoginHelper.ControlNames(drpZXZXJXS.ID, ""));
            lstControls.Add(drpZXZXJXS);

            lstCtl.Add(new LoginHelper.ControlNames(drpCLZL.ID, ""));
            lstControls.Add(drpCLZL);

            lstCtl.Add(new LoginHelper.ControlNames(txtAddress.ID, ""));
            lstControls.Add(txtAddress);

            lstCtl.Add(new LoginHelper.ControlNames(txtCSDJRQ.ID, ""));
            lstControls.Add(txtCSDJRQ);

            lstCtl.Add(new LoginHelper.ControlNames(txtFDJNumber.ID, ""));
            lstControls.Add(txtFDJNumber);

            lstCtl.Add(new LoginHelper.ControlNames(txtHDZZL.ID, ""));
            lstControls.Add(txtHDZZL);

            lstCtl.Add(new LoginHelper.ControlNames(txtHZRS.ID, ""));
            lstControls.Add(txtHZRS);

            lstCtl.Add(new LoginHelper.ControlNames(txtHPHM.ID, ""));
            lstControls.Add(txtHPHM);

            lstCtl.Add(new LoginHelper.ControlNames(txtSYR.ID, ""));
            lstControls.Add(txtSYR);

            lstCtl.Add(new LoginHelper.ControlNames(txtPP.ID, ""));
            lstControls.Add(txtPP);

            lstCtl.Add(new LoginHelper.ControlNames(txtVIN.ID, ""));
            lstControls.Add(txtVIN);

            lstCtl.Add(new LoginHelper.ControlNames(txtWKCCC.ID, ""));
            lstControls.Add(txtWKCCC);

            lstCtl.Add(new LoginHelper.ControlNames(txtWKCCG.ID, ""));
            lstControls.Add(txtWKCCG);

            lstCtl.Add(new LoginHelper.ControlNames(txtWKCCK.ID, ""));
            lstControls.Add(txtWKCCK);

            lstCtl.Add(new LoginHelper.ControlNames(txtXH.ID, ""));
            lstControls.Add(txtXH);

            lstCtl.Add(new LoginHelper.ControlNames(txtZBZL.ID, ""));
            lstControls.Add(txtZBZL);

            lstCtl.Add(new LoginHelper.ControlNames(txtZGSJCS.ID, ""));
            lstControls.Add(txtZGSJCS);

            lstCtl.Add(new LoginHelper.ControlNames(txtZZL.ID, ""));
            lstControls.Add(txtZZL);

            lstCtl.Add(new LoginHelper.ControlNames(txtAJLSH.ID, ""));
            lstControls.Add(txtAJLSH);

            lstCtl.Add(new LoginHelper.ControlNames(txtLJXSLC.ID, ""));
            lstControls.Add(txtLJXSLC);

            LoginHelper.ResetAllControls(lstCtl, lstControls);

            drpZZS_SelectedIndexChanged(null, null);

            lstItems.All(x => x.Selected = false);

            for (int i = 0; i < chkJYXM.Items.Count; i++)
            {
                chkJYXM.Items[i].Selected = false;
            }
            btnSave.Enabled = true;
            btnSave.CssClass = "btnSaveEnabled";
            LoginHelper.ResetAllValidate(GetType(), this);
        }

        protected void btnSearch_Click(object sender, EventArgs e)
        {
            string strHPHM = txtHPHMStart.Text.Trim().ToUpper() + txtHPHM.Text.Trim().ToUpper();
            string strVIN = txtVIN.Text.Trim().ToUpper();
            string strHPZL = drpHPZL.SelectedValue;

            if (string.IsNullOrEmpty(strHPHM) && string.IsNullOrEmpty(strVIN))
            {
                gfAjaxJs.SetAlertMsg(this.UpdatePanel1, "请输入号牌号码或者VIN进行查询！");
                return;
            }

            if (chkSFLW.Checked)
            {
                string strJYJGBH = "xxxx";

                string xtlb = "";//系统类别
                //接口提供者的业务类别代码，默认为“18”（代表机动车检验监管系统）
                string jkxlh = "";//接口序列号
                //由外挂系统请求服务平台授权生成下发
                string jkid = "";//接口标志
                //5位，由系统类别＋C＋两位接口顺序号组成，用于唯一表示一个接口。

                var doc = new XDocument(
                    new XElement("root",
                        new XElement("QueryCondition",
                            new XElement("hphm", strHPHM),
                            new XElement("hpzl", strHPZL),
                            new XElement("clsbdh", strVIN),
                            new XElement("jyjgbh", strJYJGBH)
                            )
                        )
                    );
                string QueryXmlDoc = doc.ToString();

                localhost.myWebService call = new localhost.myWebService();
                string result = call.queryObjectOut(xtlb, jkxlh, jkid, QueryXmlDoc);

                StringReader reader = new StringReader(result);
                XmlDocument xmlDoc = new XmlDocument();
                xmlDoc.Load(reader);
                XmlNode root = xmlDoc.SelectSingleNode("//vehispara");
                if (root != null)
                {
                    LOGIN_VEHICLE_INFO info = new LOGIN_VEHICLE_INFO();

                    info.JYLBDH = root.SelectSingleNode("jylb").InnerText;
                    info.ZYWLBDH = root.SelectSingleNode("ywlx").InnerText;
                    info.HPHM = root.SelectSingleNode("hphm").InnerText;
                    info.HPZLDH = root.SelectSingleNode("hpzl").InnerText;
                    info.VIN = root.SelectSingleNode("clsbdh").InnerText;

                    info.CLZLDH = root.SelectSingleNode("clzl").InnerText;
                    info.SYR = root.SelectSingleNode("syr").InnerText;
                    info.LXDZ = root.SelectSingleNode("zsxzqh").InnerText;
                    info.SYXZDH = root.SelectSingleNode("syxz").InnerText;
                    info.PP = root.SelectSingleNode("clpp1").InnerText;
                    info.XH = root.SelectSingleNode("clxh").InnerText;
                    info.FDJH = root.SelectSingleNode("fdjh").InnerText;
                    info.CCDJRQ = root.SelectSingleNode("ccdjrq").InnerText;
                    info.CYS = root.SelectSingleNode("hdzk").InnerText;
                    info.ZZL = root.SelectSingleNode("zzl").InnerText;
                    info.ZBZL = root.SelectSingleNode("zbzl").InnerText;
                    info.HDZH = root.SelectSingleNode("hdzzl").InnerText;
                    info.CSC = root.SelectSingleNode("cwkc").InnerText;
                    info.CSG = root.SelectSingleNode("cwkg").InnerText;
                    info.CSK = root.SelectSingleNode("cwkk").InnerText;
                    info.ZXZLXDH = root.SelectSingleNode("zxxs").InnerText;
                    info.ZXZXJXSDH = root.SelectSingleNode("zxzxjxs").InnerText;
                    info.QZDZDH = root.SelectSingleNode("qzdz").InnerText;
                    info.YGGSNFKTDH = root.SelectSingleNode("ygddtz").InnerText;
                    info.ZCZWZ = root.SelectSingleNode("zczw").InnerText;
                    info.QDXSDH = root.SelectSingleNode("qdxs").InnerText;
                    info.JZZZWZ = root.SelectSingleNode("jzzzwz").InnerText;
                    info.RLLBDH = root.SelectSingleNode("rlzl").InnerText;
                    info.ZGSJCS = root.SelectSingleNode("zgsjcs").InnerText;
                    info.LWCXWZJLDH = root.SelectSingleNode("lwcxwzjldh").InnerText;
                    info.ZZS = root.SelectSingleNode("zzs").InnerText;

                    LoadData(info);
                }
                else
                {
                    gfAjaxJs.SetAlertMsg(this.UpdatePanel1, "查询结果为空！");
                }
            }
            else
            {
                LOGIN_VEHICLE_INFO_BLL bll = new LOGIN_VEHICLE_INFO_BLL();
                string strJYLB = drpTestType.SelectedValue + ",";
                string strSql = "";
                if (!string.IsNullOrEmpty(strHPHM))
                {
                    strSql = " VEHICLEID='" + drpHPZL.SelectedValue + strHPHM + "'  and HPZLDH='" + strHPZL + "' order by ID desc";
                }
                else if (!string.IsNullOrEmpty(strVIN))
                {
                    strSql = " VIN='" + strVIN + "'  and HPZLDH='" + strHPZL + "' order by ID desc";
                }

                LOGIN_VEHICLE_INFO[] infos = bll.GetModelList(strSql);

                if (infos.Length == 1)
                {
                    LoadData(infos[0]);
                    btnSend.Enabled = false;
                    btnSend.CssClass = "btnSendDisabled";
                }
                else if (infos.Length > 1)
                {
                    gfAjaxJs.SetAlertMsg(this.UpdatePanel1, "查询结果大于1条，显示为最近记录！");
                    LoadData(infos[0]);
                    btnSend.Enabled = false;
                    btnSend.CssClass = "btnSendDisabled";
                }
                else
                {
                    gfAjaxJs.SetAlertMsg(this.UpdatePanel1, "查询结果为空！");
                    btnSend.Enabled = false;
                    btnSend.CssClass = "btnSendDisabled";
                    ResetAll();
                }
            }
        }

        private void LoadData(LOGIN_VEHICLE_INFO login_Info)
        {
            //总轴数
            if (string.IsNullOrEmpty(login_Info.ZZS) == false)
            {
                drpZZS.SelectedValue = login_Info.ZZS;
                drpZZS_SelectedIndexChanged(null, null);
            }

            List<LoginHelper.ControlNames> lstCtl = new List<LoginHelper.ControlNames>();
            List<Control> lstControls = new List<Control>();

            lstCtl.Add(new LoginHelper.ControlNames(drpTestType.ID,"JYLBDH"));
            lstControls.Add(drpTestType);

            lstCtl.Add(new LoginHelper.ControlNames(drpHPZL.ID, "HPZLDH"));
            lstControls.Add(drpHPZL);

            lstCtl.Add(new LoginHelper.ControlNames(drpLWCXWZJL.ID, "LWCXWZJLDH"));
            lstControls.Add(drpLWCXWZJL);

            lstCtl.Add(new LoginHelper.ControlNames(drpQZDZ.ID, "QZDZDH"));
            lstControls.Add(drpQZDZ);

            lstCtl.Add(new LoginHelper.ControlNames(drpRLLB.ID, "RLLBDH"));
            lstControls.Add(drpRLLB);

            lstCtl.Add(new LoginHelper.ControlNames(txtCCRQ.ID, "CCRQ"));
            lstControls.Add(txtCCRQ);

            lstCtl.Add(new LoginHelper.ControlNames(drpSYXZ.ID, "SYXZDH"));
            lstControls.Add(drpSYXZ);

            lstCtl.Add(new LoginHelper.ControlNames(drpYGGSNFKT.ID, "YGGSNFKTDH"));
            lstControls.Add(drpYGGSNFKT);

            lstCtl.Add(new LoginHelper.ControlNames(chkZCZWZ.ID, "ZCZWZ"));
            lstControls.Add(chkZCZWZ);

            lstCtl.Add(new LoginHelper.ControlNames(chkQDZWZ.ID,"QDZWZ"));
            lstControls.Add(chkQDZWZ);

            lstCtl.Add(new LoginHelper.ControlNames(drpZXZLX.ID, "ZXZLXDH"));
            lstControls.Add(drpZXZLX);

            lstCtl.Add(new LoginHelper.ControlNames(drpZXZXJXS.ID, "ZXZXJXSDH"));
            lstControls.Add(drpZXZXJXS);

            lstCtl.Add(new LoginHelper.ControlNames(drpCLZL.ID, "CLZLDH"));
            lstControls.Add(drpCLZL);

            lstCtl.Add(new LoginHelper.ControlNames(txtAddress.ID, "LXDZ"));
            lstControls.Add(txtAddress);

            lstCtl.Add(new LoginHelper.ControlNames(txtCSDJRQ.ID, "CCDJRQ"));
            lstControls.Add(txtCSDJRQ);

            lstCtl.Add(new LoginHelper.ControlNames(txtFDJNumber.ID, "FDJH"));
            lstControls.Add(txtFDJNumber);

            lstCtl.Add(new LoginHelper.ControlNames(txtHDZZL.ID, "HDZH"));
            lstControls.Add(txtHDZZL);

            lstCtl.Add(new LoginHelper.ControlNames(txtHZRS.ID, "CYS"));
            lstControls.Add(txtHZRS);

            lstCtl.Add(new LoginHelper.ControlNames(txtHPHM.ID, "HPHM"));
            lstControls.Add(txtHPHM);

            lstCtl.Add(new LoginHelper.ControlNames(txtHPHMStart.ID, "HPHM"));
            lstControls.Add(txtHPHMStart);

            lstCtl.Add(new LoginHelper.ControlNames(txtSYR.ID, "SYR"));
            lstControls.Add(txtSYR);

            lstCtl.Add(new LoginHelper.ControlNames(txtPP.ID, "PP"));
            lstControls.Add(txtPP);

            lstCtl.Add(new LoginHelper.ControlNames(txtVIN.ID, "VIN"));
            lstControls.Add(txtVIN);

            lstCtl.Add(new LoginHelper.ControlNames(txtWKCCC.ID, "CSC"));
            lstControls.Add(txtWKCCC);

            lstCtl.Add(new LoginHelper.ControlNames(txtWKCCG.ID, "CSG"));
            lstControls.Add(txtWKCCG);

            lstCtl.Add(new LoginHelper.ControlNames(txtWKCCK.ID, "CSK"));
            lstControls.Add(txtWKCCK);

            lstCtl.Add(new LoginHelper.ControlNames(txtXH.ID, "XH"));
            lstControls.Add(txtXH);

            lstCtl.Add(new LoginHelper.ControlNames(txtZBZL.ID, "ZBZL"));
            lstControls.Add(txtZBZL);

            lstCtl.Add(new LoginHelper.ControlNames(txtZGSJCS.ID, "ZGSJCS"));
            lstControls.Add(txtZGSJCS);

            lstCtl.Add(new LoginHelper.ControlNames(txtLJXSLC.ID, "LJXSLC"));
            lstControls.Add(txtLJXSLC);

            lstCtl.Add(new LoginHelper.ControlNames(txtZZL.ID, "ZZL"));
            lstControls.Add(txtZZL);

            lstCtl.Add(new LoginHelper.ControlNames(txtAJLSH.ID, "AJLSH"));
            lstControls.Add(txtAJLSH);

            LoginHelper.LoadData(login_Info, lstCtl, lstControls);

            if (login_Info.SFSQCLC == "1")
            {
                chkQCLC.Checked = true;
                trOperater.Visible = false;
                divGC.Visible = true;
                BindQCLC(login_Info.GLCHPHM, login_Info.GLCHPZLDH);
            }
            else
            {
                chkQCLC.Checked = false;
                trOperater.Visible = true;
                divGC.Visible = false;
            }

            drpQZDZ_SelectedIndexChanged(null, null);

            string strJYXM = "";
            LoginHelper.ConfirmJCXS(login_Info, "A", rbtnTest, lblJCCS, out strJYXM);

            if (rbtnTest.SelectedValue == "0")
            {
                strJYXM = login_Info.JYXM;
            }

            LoginHelper.BindJYXM(strJYXM, chkJYXM, lstItems);

            btnSave.Enabled = true;
            btnSave.CssClass = "btnSaveEnabled";

            LoginHelper.ResetAllValidate(GetType(),this);
        }

        private void BindQCLC(string strHPHMGC, string strHPZLDHGC)
        {
            var vInfo = LoginHelper.GetLoginInfo(strHPHMGC, strHPZLDHGC);

            //总轴数
            if (string.IsNullOrEmpty(vInfo.ZZS) == false)
            {
                drpZZSGC.SelectedValue = vInfo.ZZS;
                drpZZSGC_SelectedIndexChanged(null, null);
            }

            List<LoginHelper.ControlNames> lstCtl = new List<LoginHelper.ControlNames>();
            List<Control> lstControls = new List<Control>();

            lstCtl.Add(new LoginHelper.ControlNames(drpTestTypeGC.ID, "JYLBDH"));
            lstControls.Add(drpTestTypeGC);

            lstCtl.Add(new LoginHelper.ControlNames(txtAJLSHGC.ID, "AJLSH"));
            lstControls.Add(txtAJLSHGC);

            lstCtl.Add(new LoginHelper.ControlNames(txtHPHMGC.ID, "HPHM"));
            lstControls.Add(txtHPHMGC);

            lstCtl.Add(new LoginHelper.ControlNames(txtHPHMStartGC.ID, "HPHM"));
            lstControls.Add(txtHPHMStartGC);

            lstCtl.Add(new LoginHelper.ControlNames(drpHPZLGC.ID, "HPZLDH"));
            lstControls.Add(drpHPZLGC);

            lstCtl.Add(new LoginHelper.ControlNames(chkZCZWZGC.ID, "ZCZWZ"));
            lstControls.Add(chkZCZWZGC);

            lstCtl.Add(new LoginHelper.ControlNames(txtVINGC.ID, "VIN"));
            lstControls.Add(txtVINGC);

            lstCtl.Add(new LoginHelper.ControlNames(drpCLZLGC.ID, "CLZLDH"));
            lstControls.Add(drpCLZLGC);

            lstCtl.Add(new LoginHelper.ControlNames(txtSYRGC.ID, "SYR"));
            lstControls.Add(txtSYRGC);

            lstCtl.Add(new LoginHelper.ControlNames(txtAddressGC.ID, "LXDZ"));
            lstControls.Add(txtAddressGC);

            lstCtl.Add(new LoginHelper.ControlNames(txtTelGC.ID, "LXDH"));
            lstControls.Add(txtTelGC);

            lstCtl.Add(new LoginHelper.ControlNames(drpSYXZGC.ID, "SYXZDH"));
            lstControls.Add(drpSYXZGC);

            lstCtl.Add(new LoginHelper.ControlNames(txtPPGC.ID, "PP"));
            lstControls.Add(txtPPGC);

            lstCtl.Add(new LoginHelper.ControlNames(txtXHGC.ID, "XH"));
            lstControls.Add(txtXHGC);

            lstCtl.Add(new LoginHelper.ControlNames(txtCCRQGC.ID, "CCRQ"));
            lstControls.Add(txtCCRQGC);

            lstCtl.Add(new LoginHelper.ControlNames(txtCCDJRQGC.ID, "CCDJRQ"));
            lstControls.Add(txtCCDJRQGC);

            lstCtl.Add(new LoginHelper.ControlNames(txtZZLGC.ID, "ZZL"));
            lstControls.Add(txtZZLGC);

            lstCtl.Add(new LoginHelper.ControlNames(txtZBZLGC.ID, "ZBZL"));
            lstControls.Add(txtZBZLGC);

            lstCtl.Add(new LoginHelper.ControlNames(txtHDZZLGC.ID, "HDZH"));
            lstControls.Add(txtHDZZLGC);

            lstCtl.Add(new LoginHelper.ControlNames(txtCSCGC.ID, "CSC"));
            lstControls.Add(txtCSCGC);

            lstCtl.Add(new LoginHelper.ControlNames(txtCSKGC.ID, "CSK"));
            lstControls.Add(txtCSKGC);

            lstCtl.Add(new LoginHelper.ControlNames(txtCSGGC.ID, "CSG"));
            lstControls.Add(txtCSGGC);

            lstCtl.Add(new LoginHelper.ControlNames(drpLWCXGC.ID, "LWCXWZJLDH"));
            lstControls.Add(drpLWCXGC);

            LoginHelper.LoadData(vInfo, lstCtl, lstControls);

            string strJYXM = "";
            LoginHelper.ConfirmJCXS(vInfo, "A", rbtnTestGC,lblJCCSGC,out strJYXM);
            if (rbtnTestGC.SelectedValue == "0")
            {
                strJYXM = vInfo.JYXM;
            }

            LoginHelper.BindJYXM(strJYXM, chkJYXMGC, lstItemsGC);
            LoginHelper.ResetAllValidate(GetType(), this);
        }

        private static LOGIN_VEHICLE_INFO GetData(string xmlString)
        {
            Model.LOGIN_VEHICLE_INFO info = new LOGIN_VEHICLE_INFO();
            XmlDocument doc = new XmlDocument();
            doc.LoadXml(xmlString);
            XmlNodeList xxList = doc.GetElementsByTagName("body");
            foreach (XmlNode xxNode in xxList)
            {
                XmlNodeList childList = xxNode.ChildNodes;
                foreach (XmlNode node in childList)
                {
                    string temp = node.Name;
                    switch (temp)
                    {
                        case "clxh":
                            info.XH = node.InnerText;
                            break;
                        case "zzl":
                            info.ZZL = node.InnerText;
                            break;

                    }
                }
            }
            return info;
        }

        protected void btnReset_Click(object sender, EventArgs e)
        {
            ResetAll();
        }

        protected void btnSend_Click(object sender, EventArgs e)
        {
            bool bIsFirstTest_ZC = rbtnTest.SelectedValue == "0" ? true : false;//是否为初检

            //bool bHasCharge = LoginHelper.HasCharge(hidID.Value, "A", bIsFirstTest_ZC);
            //if (!bHasCharge)
            //{
            //    gfAjaxJs.SetAlertMsg(this.UpdatePanel1, "当前车辆没有收费，请收费后在发送！");
            //    return;
            //}

            LoginHelper.ResetAllValidate(GetType(),this);

            var dicCheckItems = LoginHelper.CheckAllInputItems(hidID.Value, "", "A");
            if (dicCheckItems["A"].Count > 0)
            {
                foreach (var v in dicCheckItems["A"])
                {
                    TextBox txt = (TextBox)this.FindControl(v);
                    txt.BackColor = Color.Yellow;
                }
                return;
            }

            LOGIN_VEHICLE_INFO_BLL info_bll = new LOGIN_VEHICLE_INFO_BLL();
            var info = info_bll.GetModel(Convert.ToInt32(hidID.Value));
            if (string.IsNullOrEmpty(info.JYXM))
            {
                gfAjaxJs.SetAlertMsg(this.UpdatePanel1, "请选择检验项目保存后，在进行发送！");
                return;
            }

            bool bIsUpdate_ZC;
            VEHICLE_DISPATCH model_ZC = LoginHelper.GetDispathchByLoginID(hidID.Value, "A", bIsFirstTest_ZC, out bIsUpdate_ZC);

            VEHICLE_DISPATCH_BLL disBll = new VEHICLE_DISPATCH_BLL();

            if (!bIsUpdate_ZC)
            {
                if (disBll.Insert(model_ZC))
                {
                    gfAjaxJs.SetAlertMsg(UpdatePanel1, "发送成功！");
                    btnSend.CssClass = "btnSendDisabled";
                    btnSend.Enabled = false;
                    ResetAll();
                    LoginedList1.BindList("", "");
                    return;
                }
                else
                {
                    gfAjaxJs.SetAlertMsg(UpdatePanel1, "发送失败！");
                    btnSend.CssClass = "btnSendEnabled";
                    btnSend.Enabled = true;
                    return;
                }
            }
            else
            {
                if (disBll.Update(model_ZC, model_ZC.JCLSH))
                {
                    gfAjaxJs.SetAlertMsg(UpdatePanel1, "发送成功！");
                    btnSend.CssClass = "btnSendDisabled";
                    btnSend.Enabled = false;
                    ResetAll();
                    return;
                }
                else
                {
                    gfAjaxJs.SetAlertMsg(UpdatePanel1, "发送失败！");
                    btnSend.CssClass = "btnSendEnabled";
                    btnSend.Enabled = true;
                    return;
                }
            }
        }

        protected void drpZZS_SelectedIndexChanged(object sender, EventArgs e)
        {
            ReBindJCXM();
            int iZZS = Convert.ToInt32(drpZZS.SelectedValue);
            LoginHelper.BindZCZWZ(iZZS, chkZCZWZ, chkQDZWZ);
        }


        private void ReBindJCXM()
        {
            int iZZS = Convert.ToInt32(drpZZS.SelectedValue);
            int iQZDE = Convert.ToInt32(drpQZDZ.SelectedValue);

            for (int i = 0; i < chkJYXM.Items.Count; i++)
            {
                foreach (var vItem in lstItems)
                {
                    if (chkJYXM.Items[i].Selected && chkJYXM.Items[i].Value == vItem.Value)
                    {
                        vItem.Selected = true;
                    }
                }
            }

            chkJYXM.Items.Clear();

            for (int i = 0; i < lstItems.Count; i++)
            {
                if (lstItems[i].Value.Substring(0, 1) == "B")
                {
                    if (Convert.ToInt32(lstItems[i].Value.Substring(1, 1)) <= iZZS)
                    {
                        chkJYXM.Items.Add(lstItems[i]);
                    }
                }
                else if (lstItems[i].Value.Substring(0, 1) == "Z")
                {
                    if (Convert.ToInt32(lstItems[i].Value.Substring(1, 1)) <= iZZS)
                    {
                        chkJYXM.Items.Add(lstItems[i]);
                    }
                }

                else if (lstItems[i].Value.Substring(0, 1) == "H")
                {
                    if (iQZDE == 2)
                    {
                        if (Convert.ToInt32(lstItems[i].Value.Substring(1, 1)) == 1 || Convert.ToInt32(lstItems[i].Value.Substring(1, 1)) == 4)
                        {
                            chkJYXM.Items.Add(lstItems[i]);
                        }
                    }
                    else
                    {
                        chkJYXM.Items.Add(lstItems[i]);
                    }
                }
                else
                {
                    chkJYXM.Items.Add(lstItems[i]);
                }
            }
        }

        //绑定挂车检验项目
        private void ReBindJCXMGC()
        {
            int iZZS = Convert.ToInt32(drpZZSGC.SelectedValue);

            for (int i = 0; i < chkJYXMGC.Items.Count; i++)
            {
                foreach (var vItem in lstItemsGC)
                {
                    if (chkJYXMGC.Items[i].Selected && chkJYXMGC.Items[i].Value == vItem.Value)
                    {
                        vItem.Selected = true;
                    }
                }
            }

            chkJYXMGC.Items.Clear();

            for (int i = 0; i < lstItemsGC.Count; i++)
            {
                if (lstItemsGC[i].Value.Substring(0, 1) == "B")
                {
                    if (Convert.ToInt32(lstItemsGC[i].Value.Substring(1, 1)) <= iZZS)
                    {
                        chkJYXMGC.Items.Add(lstItemsGC[i]);
                    }
                }
                else if (lstItemsGC[i].Value.Substring(0, 1) == "Z")
                {
                    if (Convert.ToInt32(lstItemsGC[i].Value.Substring(1, 1)) <= iZZS)
                    {
                        chkJYXMGC.Items.Add(lstItemsGC[i]);
                    }
                }

                else if (lstItemsGC[i].Value.Substring(0, 1) == "H")
                {

                }
                else
                {
                    chkJYXMGC.Items.Add(lstItemsGC[i]);
                }
            }
        }

        protected void drpQZDZ_SelectedIndexChanged(object sender, EventArgs e)
        {
            ReBindJCXM();
        }

        protected void chkJYXM_SelectedIndexChanged(object sender, EventArgs e)
        {
            bool bFirstTest = rbtnTest.SelectedValue == "0" ? true : false;

            bool bIsSLQC = drpCLZL.SelectedValue == "N11" ? true : false;
            LoginHelper.JYXMChanged(chkJYXM, lstItems, bFirstTest, bIsSLQC);
        }

        protected void chkZCZWZ_SelectedIndexChanged(object sender, EventArgs e)
        {
            bool b = false;
            for (int i = 0; i < chkZCZWZ.Items.Count; i++)
            {
                if (chkZCZWZ.Items[i].Selected)
                {
                    b = true;
                }
            }

            if (b == false)
            {
                gfAjaxJs.SetAlertMsg(this.UpdatePanel1, "必须选择一个驻车轴！");
                chkZCZWZ.Items[1].Selected = true;
                return;
            }
        }

        protected void btnFilter_Click(object sender, EventArgs e)
        {
            List<string> lstSelected = new List<string>();
            int iVehicleClass = 0;
            string strJYLB = drpTestType.SelectedValue;
            string strCLZL = drpCLZL.SelectedValue;
            string strSYXZ = drpSYXZ.SelectedValue;

            int iCYS = 0;
            if (!string.IsNullOrEmpty(txtHZRS.Text) && gfLibrary.gfValidate.Is_Integer(txtHZRS.Text))
            {
                iCYS = Convert.ToInt32(txtHZRS.Text);
            }

            bool IsOut10Year = false;
            if (!string.IsNullOrEmpty(txtCSDJRQ.Text) && gfValidate.Is_DateTime(txtCSDJRQ.Text))
            {
                IsOut10Year = Convert.ToDateTime(txtCSDJRQ.Text).AddYears(10) < DateTime.Now ? true : false;
            }

            string strLW = drpLWCXWZJL.SelectedValue;

            int iZZS = Convert.ToInt32(drpZZS.SelectedValue);

            string strZXXJXS = drpZXZXJXS.SelectedValue;
            string strZXZLX = drpZXZLX.SelectedValue;


            if (strCLZL == "N11")
            {// 三轮汽车
                iVehicleClass = 4;
            }
            else
            {
                if (strCLZL.Substring(0, 1) == "K")
                {// 客车
                    iVehicleClass = 1;
                    if (strSYXZ.Substring(0, 1) == "F")
                    {// 非营运
                        if (strCLZL.Substring(1, 1) == "3" || strCLZL.Substring(1, 1) == "4")
                        {// 非营运小型、微型载客汽车
                            iVehicleClass = 0;
                        }
                    }
                }
                else
                { // 载货汽车（三轮汽车除外）、专项作业车
                    iVehicleClass = 2;
                }
            }

            if (strCLZL.Substring(0, 1) == "H")
            {// ZL 2016-11-20 在用车检验时,仅对中、重型货车、挂车检测,见GB21861-2014 第6.3.1外廓尺寸
                if (strJYLB == "01" || strJYLB == "05")
                {
                    lstSelected.Add("M1"); //外廓尺寸
                }
                else if (strJYLB == "02" )
                {
                    lstSelected.Add("W1");
                }
            }

            if (strJYLB == "01" || strJYLB == "05")
            {
                switch (iVehicleClass)
                {
                    case 0://非营运小型、微型载客汽车
                        lstSelected.Add("F1");// 外观
                        for (int i = 1; i <= iZZS; i++)
                        {
                            // 行车制动 
                            lstSelected.Add("B" + i);
                            lstSelected.Add("Z" + i);
                        }
                        for (int i = 1; i < 5; i++)
                        {// 灯光
                            lstSelected.Add("H" + i);
                        }

                        if ((iCYS >= 7) || strCLZL == "K39" || strCLZL == "K49" || IsOut10Year)
                        {
                            lstSelected.Add("B0");// 驻车
                            lstSelected.Add("DC");// 动态底盘
                            lstSelected.Add("C1");// 底盘部件
                        }
                        // 联网查询有交通事故的，增加底盘 和动态底盘检验
                        if (strLW == "1") // 具有交通事故的 
                        {
                            lstSelected.Add("DC");// 动态底盘
                            lstSelected.Add("C1");// 底盘部件
                        }
                        break;
                    case 1://其它类型载客汽车
                    case 2://载货汽车（三轮汽车除外）、专项作业车
                        lstSelected.Add("F1");// 外观
                        lstSelected.Add("S1");// 车速表

                        for (int i = 1; i <= iZZS; i++)
                        {
                            // 行车制动 
                            lstSelected.Add("B" + i);
                            lstSelected.Add("Z" + i);
                        }
                        for (int i = 1; i < 5; i++)
                        {// 灯光
                            lstSelected.Add("H" + i);
                        }
                        lstSelected.Add("B0");// 驻车
                        lstSelected.Add("DC");// 动态底盘
                        lstSelected.Add("C1");// 底盘部件

                        if (strZXXJXS == "1" && strZXZLX == "1") // 非独立悬架 非双转向的车要检测侧滑
                        {
                            lstSelected.Add("A1"); ;// 侧滑
                        }
                        break;
                    case 4://三轮汽车
                        lstSelected.Add("F1");// 外观
                        lstSelected.Add("P9");// 外观
                        for (int i = 1; i <= iZZS; i++)
                        {
                            // 行车制动 
                            lstSelected.Add("B" + i);
                            lstSelected.Add("Z" + i);
                        }
                        for (int i = 1; i < 5; i++)
                        {// 灯光
                            lstSelected.Add("H" + i);
                        }
                        lstSelected.Add("DC");// 动态底盘
                        lstSelected.Add("C1");// 底盘部件
                        lstSelected.Add("P7");// 动态底盘
                        lstSelected.Add("P8");// 底盘部件
                        lstSelected.Add("P0");// 驻车制动
                        break;
                }
            }
            else if (strJYLB == "02")
            {
                lstSelected.Add("M1");
                lstSelected.Add("W1");

                switch (iVehicleClass)
                {
                    case 0://非营运小型、微型载客汽车
                        lstSelected.Add("F1");// 外观
                        lstSelected.Add("S1");// 外观
                        for (int i = 1; i <= iZZS; i++)
                        {
                            // 行车制动 
                            lstSelected.Add("B" + i);
                            lstSelected.Add("Z" + i);
                        }
                        for (int i = 1; i < 5; i++)
                        {// 灯光
                            lstSelected.Add("H" + i);
                        }

                        if ((iCYS >= 7) || strCLZL == "K39" || strCLZL == "K49" || IsOut10Year)
                        {
                            lstSelected.Add("B0");// 驻车
                            lstSelected.Add("DC");// 动态底盘
                            lstSelected.Add("C1");// 底盘部件
                        }
                        // 联网查询有交通事故的，增加底盘 和动态底盘检验
                        if (strLW == "1") // 具有交通事故的 
                        {
                            lstSelected.Add("DC");// 动态底盘
                            lstSelected.Add("C1");// 底盘部件
                        }
                        break;
                    case 1://其它类型载客汽车
                    case 2://载货汽车（三轮汽车除外）、专项作业车
                        lstSelected.Add("F1");// 外观
                        lstSelected.Add("S1");// 车速表
                        for (int i = 1; i <= iZZS; i++)
                        {
                            // 行车制动 
                            lstSelected.Add("B" + i);
                            lstSelected.Add("Z" + i);
                        }
                        for (int i = 1; i < 5; i++)
                        {// 灯光
                            lstSelected.Add("H" + i);
                        }
                        lstSelected.Add("B0");// 驻车
                        lstSelected.Add("DC");// 动态底盘
                        lstSelected.Add("C1");// 底盘部件
                        // 侧滑
                        if (strZXXJXS == "1" && strZXZLX == "1") // 非独立悬架 非双转向的车要检测侧滑
                        {
                            lstSelected.Add("A1"); ;// 侧滑
                        }
                        break;
                    case 4://三轮汽车
                        lstSelected.Add("P9");// 外观
                        for (int i = 1; i <= iZZS; i++)
                        {
                            // 行车制动 
                            lstSelected.Add("B" + i);
                            lstSelected.Add("Z" + i);
                        }
                        for (int i = 1; i < 5; i++)
                        {// 灯光
                            lstSelected.Add("H" + i);
                        }
                        lstSelected.Add("DC");// 动态底盘
                        lstSelected.Add("C1");// 底盘部件
                        lstSelected.Add("P7");// 动态底盘
                        lstSelected.Add("P8");// 底盘部件
                        lstSelected.Add("P0");// 驻车制动
                        break;
                }
            }

            lstItems.All(x => x.Selected = false);

            foreach (var vSelected in lstSelected)
            {
                foreach (var vItem in lstItems)
                {
                    if (vSelected == vItem.Value)
                    {
                        vItem.Selected = true;
                    }
                }
            }


            for (int i = 0; i < chkJYXM.Items.Count; i++)
            {
                chkJYXM.Items[i].Selected = false;
                foreach (var v in lstSelected)
                {
                    if (chkJYXM.Items[i].Value == v)
                    {
                        chkJYXM.Items[i].Selected = true;
                    }
                }
            }
        }

        protected void chkQDZWZ_SelectedIndexChanged(object sender, EventArgs e)
        {
            bool b = false;
            for (int i = 0; i < chkQDZWZ.Items.Count; i++)
            {
                if (chkQDZWZ.Items[i].Selected)
                {
                    b = true;
                }
            }

            if (b == false)
            {
                gfAjaxJs.SetAlertMsg(this.UpdatePanel1, "必须选择一个驱动轴！");
                chkQDZWZ.Items[1].Selected = true;
                return;
            }
        }

        protected void chkQCLC_CheckedChanged(object sender, EventArgs e)
        {
            if (chkQCLC.Checked)
            {
                trOperater.Visible = false;
                divGC.Visible = true;
            }
            else
            {
                trOperater.Visible = true;
                divGC.Visible = false;
            }
        }

        protected void drpZZSGC_SelectedIndexChanged(object sender, EventArgs e)
        {
            ReBindJCXMGC();
            int iZZS = Convert.ToInt32(drpZZSGC.SelectedValue);
            LoginHelper.BindZCZWZ(iZZS, chkZCZWZGC);
        }

        protected void chkZCZWZGC_SelectedIndexChanged(object sender, EventArgs e)
        {
            bool b = false;
            for (int i = 0; i < chkZCZWZGC.Items.Count; i++)
            {
                if (chkZCZWZGC.Items[i].Selected)
                {
                    b = true;
                }
            }

            if (b == false)
            {
                gfAjaxJs.SetAlertMsg(this.UpdatePanel1, "必须选择一个驻车轴！");
                chkZCZWZGC.Items[1].Selected = true;
                return;
            }
        }

        protected void btnSaveGC_Click(object sender, EventArgs e)
        {
            #region 主车信息
            //安检检验登录
            string strJYLB = drpTestType.SelectedValue.Trim() + ",";
            string strHPHM_C = txtHPHM.Text.Trim().ToUpper();
            string strHPHM_H = txtHPHMStart.Text.Trim().ToUpper();
            string strHPHM = strHPHM_H + strHPHM_C;
            string strHPZL = drpHPZL.SelectedValue.Trim();
            string strVIN = txtVIN.Text.Trim().ToUpper();
            string strSYR = txtSYR.Text.Trim();
            string strAddress = txtAddress.Text.Trim();
            string strPP = txtPP.Text.Trim();
            string strXH = txtXH.Text.Trim().ToUpper();
            string strFDJHM = txtFDJNumber.Text.Trim().ToUpper();
            string strCCRQ = txtCCRQ.Text.Trim();
            string strCSDJRQ = txtCSDJRQ.Text.Trim();
            string strZZL = txtZZL.Text.Trim();
            string strHZRS = txtHZRS.Text.Trim();
            string strZBZL = txtZBZL.Text.Trim();
            string strWKCCC = txtWKCCC.Text.Trim();
            string strWKCCK = txtWKCCK.Text.Trim();
            string strWKCCG = txtWKCCG.Text.Trim();
            //驻车轴位置
            string strZCZWZ = "";
            //驱动轴位置
            string strQDZWZ = "";
            string strHDZZL = txtHDZZL.Text.Trim();
            string strZGSJCS = txtZGSJCS.Text.Trim();
            string strLJXSLC = txtLJXSLC.Text.Trim();
            string strJYXM = "";

            if (string.IsNullOrEmpty(strHPHM_H))
            {
                gfAjaxJs.SetAlertMsg(this.UpdatePanel1, "号牌号码开头不能为空！");
                txtHPHMStart.Focus();
                txtHPHMStart.BackColor = Color.Yellow;
                return;
            }
            else
            {
                txtHPHMStart.BackColor = Color.White;
            }

            if (string.IsNullOrEmpty(strHPHM))
            {
                gfAjaxJs.SetAlertMsg(this.UpdatePanel1, "号牌号码不能为空！");
                txtHPHM.Focus();
                txtHPHM.BackColor = Color.Yellow;
                return;
            }
            else
            {
                txtHPHM.BackColor = Color.White;
            }

            if (string.IsNullOrEmpty(strVIN) ==false)
            {
                txtVIN.BackColor = Color.White;
            }

            if (string.IsNullOrEmpty(strSYR) == false)
            {
                txtSYR.BackColor = Color.White;
            }

            if (string.IsNullOrEmpty(strAddress) == false)
            {
                txtAddress.BackColor = Color.White;
            }

            if (string.IsNullOrEmpty(strPP) == false)
            {
                txtPP.BackColor = Color.White;
            }

            if (string.IsNullOrEmpty(strXH) == false)
            {
                txtXH.BackColor = Color.White;
            }

            if (string.IsNullOrEmpty(strFDJHM) == false)
            {
                txtFDJNumber.BackColor = Color.White;
            }

            if (string.IsNullOrEmpty(strCCRQ) == false)
            {
                if (gfValidate.Is_DateTime(strCCRQ) == false)
                {
                    gfAjaxJs.SetAlertMsg(this.UpdatePanel1, "出厂日期不是有效的日期格式！");
                    txtCCRQ.BackColor = Color.Yellow;
                    return;
                }
                else
                {
                    txtCCRQ.BackColor = Color.White;
                }
            }

            if (string.IsNullOrEmpty(strCSDJRQ) == false)
            {
                if (gfValidate.Is_DateTime(strCSDJRQ) == false)
                {
                    gfAjaxJs.SetAlertMsg(this.UpdatePanel1, "初始登记日期不是日期格式！");
                    txtCSDJRQ.BackColor = Color.Yellow;
                    return;
                }
                else
                {
                    txtCSDJRQ.BackColor = Color.White;
                }
            }

            if (string.IsNullOrEmpty(strHZRS) == false)
            {
                if (!gfValidate.Is_Integer(strHZRS))
                {
                    gfAjaxJs.SetAlertMsg(this.UpdatePanel1, "核载人数只能为整数！");
                    txtHZRS.BackColor = Color.Yellow;
                    return;
                }
                else
                {
                    txtHZRS.BackColor = Color.White;
                }
            }

            if (string.IsNullOrEmpty(strZZL) == false)
            {
                if (!gfValidate.Is_Integer(strZZL))
                {
                    gfAjaxJs.SetAlertMsg(this.UpdatePanel1, "总质量只能为整数！");
                    txtZZL.BackColor = Color.Yellow;
                    return;
                }
                else
                {
                    txtZZL.BackColor = Color.White;
                }
            }

            if (string.IsNullOrEmpty(strZBZL) == false)
            {
                if (!gfValidate.Is_Integer(strZBZL))
                {
                    gfAjaxJs.SetAlertMsg(this.UpdatePanel1, "整备质量只能为整数！");
                    txtZBZL.Focus();
                    txtZBZL.BackColor = Color.Yellow;
                    return;
                }
                {
                    txtZBZL.BackColor = Color.White;
                }
            }

           

            if (string.IsNullOrEmpty(strWKCCC) ==false)
            {
                if (!gfValidate.Is_Integer(strWKCCC))
                {
                    gfAjaxJs.SetAlertMsg(this.UpdatePanel1, "外廓尺寸长只能为整数！");
                    txtWKCCC.Focus();
                    txtWKCCC.BackColor = Color.Yellow;
                    return;
                }
                else
                {
                    txtWKCCC.BackColor = Color.White;
                }
            }

            if (string.IsNullOrEmpty(strWKCCK))
            {
                if (!gfValidate.Is_Integer(strWKCCK))
                {
                    gfAjaxJs.SetAlertMsg(this.UpdatePanel1, "外廓尺寸宽只能为整数！");
                    txtWKCCK.Focus();
                    txtWKCCK.BackColor = Color.Yellow;
                    return;
                }
                else
                {
                    txtWKCCK.BackColor = Color.White;
                }
            }

            if (string.IsNullOrEmpty(strWKCCG))
            {
                if (!gfValidate.Is_Integer(strWKCCG))
                {
                    gfAjaxJs.SetAlertMsg(this.UpdatePanel1, "外廓尺寸高只能为整数！");
                    txtWKCCG.Focus();
                    txtWKCCG.BackColor = Color.Yellow;
                    return;
                }
                else
                {
                    txtWKCCG.BackColor = Color.White;
                }
            }

            for (int i = 0; i < chkZCZWZ.Items.Count; i++)
            {
                if (chkZCZWZ.Items[i].Selected)
                {
                    strZCZWZ += chkZCZWZ.Items[i].Value + ",";
                }
            }

            for (int i = 0; i < chkQDZWZ.Items.Count; i++)
            {
                if (chkQDZWZ.Items[i].Selected)
                {
                    strQDZWZ += chkQDZWZ.Items[i].Value + ",";
                }
            }

            if (!string.IsNullOrEmpty(strHDZZL) && !gfValidate.Is_Integer(strHDZZL))
            {
                gfAjaxJs.SetAlertMsg(this.UpdatePanel1, "核定载质量只能为整数！");
                txtHDZZL.Focus();
                txtHDZZL.BackColor = Color.Yellow;
                return;
            }
            else
            {
                txtHDZZL.BackColor = Color.White;
            }

            if (string.IsNullOrEmpty(strZGSJCS) == false)
            {
                if (!gfValidate.Is_Integer(strZGSJCS))
                {
                    gfAjaxJs.SetAlertMsg(this.UpdatePanel1, "[最高设计车速]只能为整数！");
                    txtZGSJCS.BackColor = Color.Yellow;
                }
                else
                {
                    txtZGSJCS.BackColor = Color.White;
                }
            }

            //累计行驶里程
            if (string.IsNullOrEmpty(strLJXSLC) == false)
            {
                if (!gfLibrary.gfValidate.Is_Float(strLJXSLC))
                {
                    gfAjaxJs.SetAlertMsg(this.UpdatePanel1, "[累计行驶里程]不是有效的数字格式！");
                    txtLJXSLC.BackColor = Color.Yellow;
                }
                else
                {
                    txtLJXSLC.BackColor = Color.White;
                }
            }

            for (int i = 0; i < chkJYXM.Items.Count; i++)
            {
                if (chkJYXM.Items[i].Selected)
                {
                    strJYXM += chkJYXM.Items[i].Value + ",";
                }
            }

            string strSFSQCLC = chkQCLC.Checked ? "1" : "0";
            string strVEHICLEID = strHPZL + strHPHM;
            #endregion

            #region 挂车信息
            string strTestTypeGC = drpTestTypeGC.SelectedValue + ",";
            string strAJLSHGC = txtAJLSHGC.Text.Trim();
            string strHPHMGC_C = txtHPHMGC.Text.Trim().ToUpper();
            string strHPHMGC_H = txtHPHMStartGC.Text.Trim().ToUpper();
            string strHPHMGC = strHPHMGC_H + strHPHMGC_C;

            if (!strHPHMGC.Contains("挂"))
            {
                strHPHMGC += "挂";
            }
            string strHPZLGC = drpHPZLGC.SelectedValue;
            string strVINGC = txtVINGC.Text.Trim().ToUpper();

            string strCLZLGC = drpCLZLGC.SelectedValue;
            string strSYRGC = txtSYRGC.Text.Trim();
            string strAddressGC = txtAddressGC.Text.Trim();
            string strTelGC = txtTelGC.Text.Trim();
            string strSYXZGC = drpSYXZGC.SelectedValue;
            string strPPGC = txtPPGC.Text.Trim();
            string strXHGC = txtXHGC.Text.Trim().ToUpper();
            string strCCRQGC = txtCCRQGC.Text.Trim();
            string strCCDJRQGC = txtCCDJRQGC.Text.Trim();
            string strZZLGC = txtZZLGC.Text.Trim();
            string strZBZLGC = txtZBZLGC.Text.Trim();
            string strHDZZLGC = txtHDZZLGC.Text.Trim();
            string strZZSGC = drpZZSGC.SelectedValue;
            string strZCZWZGC = "";
            string strCSCGC = txtCSCGC.Text.Trim();
            string strCSKGC = txtCSKGC.Text.Trim();
            string strCSGGC = txtCSGGC.Text.Trim();
            string strTestStatus = rbtnTestGC.SelectedValue;
            string strLWCXGC = drpLWCXGC.SelectedValue;

            if (string.IsNullOrEmpty(strHPHMGC_H))
            {
                gfAjaxJs.SetAlertMsg(this.UpdatePanel1, "挂车号牌号码开头不能为空！");
                txtHPHMStartGC.Focus();
                txtHPHMStartGC.BackColor = Color.Yellow;
                return;
            }
            else
            {
                txtHPHMStartGC.BackColor = Color.White;
            }

            if (string.IsNullOrEmpty(strHPHMGC_C))
            {
                gfAjaxJs.SetAlertMsg(this.UpdatePanel1, "挂车号牌号码不能为空！");
                txtHPHMGC.Focus();
                txtHPHMGC.BackColor = Color.Yellow;
                return;
            }
            else
            {
                txtHPHMGC.BackColor = Color.White;
            }

            if (string.IsNullOrEmpty(strVINGC) ==false)
            {
                txtVINGC.BackColor = Color.White;
            }

            if (string.IsNullOrEmpty(strSYRGC) == false)
            {
                txtSYRGC.BackColor = Color.White;
            }

            if (string.IsNullOrEmpty(strAddressGC) == false)
            {
                txtAddressGC.BackColor = Color.White;
            }

            if (string.IsNullOrEmpty(strTelGC) == false)
            {
                txtTelGC.BackColor = Color.White;
            }

            if (string.IsNullOrEmpty(strPPGC) == false)
            {
                txtPPGC.BackColor = Color.White;
            }

            if (string.IsNullOrEmpty(strXHGC) == false)
            {
                txtXHGC.BackColor = Color.White;
            }

            if (string.IsNullOrEmpty(strCCRQGC) == false)
            {
                if (gfValidate.Is_DateTime(strCCRQGC) == false)
                {
                    gfAjaxJs.SetAlertMsg(this.UpdatePanel1, "挂车出厂年月不是有效的日期格式！");
                    txtCCRQGC.Focus();
                    txtCCRQGC.BackColor = Color.Yellow;
                    return;
                }
                else
                {
                    txtCCRQGC.BackColor = Color.White;
                }
            }

            if (string.IsNullOrEmpty(strCCDJRQGC) == false)
            {
                if (gfValidate.Is_DateTime(strCCRQGC) == false)
                {
                    gfAjaxJs.SetAlertMsg(this.UpdatePanel1, "挂车初始登记日期不是有效的日期格式！");
                    txtCCDJRQGC.Focus();
                    txtCCDJRQGC.BackColor = Color.Yellow;
                    return;
                }
                else
                {
                    txtCCDJRQGC.BackColor = Color.White;
                }
            }

            if (string.IsNullOrEmpty(strZZLGC) == false)
            {
                txtZZLGC.BackColor = Color.White;
            }

            if (string.IsNullOrEmpty(strZBZLGC) == false)
            {
                txtZBZLGC.BackColor = Color.White;
            }

            if (string.IsNullOrEmpty(strCSCGC) == false)
            {
                txtCSCGC.BackColor = Color.White;
            }


            if (string.IsNullOrEmpty(strCSKGC) == false)
            {
                txtCSKGC.BackColor = Color.White;
            }

            if (string.IsNullOrEmpty(strCSGGC) == false)
            {
                txtCSGGC.BackColor = Color.White;
            }

            string strJYXMGC = "";
            //bool bGC = false;
            //for (int i = 0; i < chkJYXMGC.Items.Count; i++)
            //{
            //    if (chkJYXMGC.Items[i].Selected)
            //    {
            //        bGC = true;
            //        break;
            //    }
            //}

            //if (bGC == false)
            //{
            //    gfAjaxJs.SetAlertMsg(this.UpdatePanel1, "请选择挂车检验项目！");
            //    return;
            //}

            for (int i = 0; i < chkJYXMGC.Items.Count; i++)
            {
                if (chkJYXMGC.Items[i].Selected)
                {
                    strJYXMGC += chkJYXMGC.Items[i].Value + ",";
                }
            }

            for (int i = 0; i < chkZCZWZGC.Items.Count; i++)
            {
                if (chkZCZWZGC.Items[i].Selected)
                {
                    strZCZWZGC += chkZCZWZGC.Items[i].Value + ",";
                }
            }

            string strFirstTestGC = rbtnTestGC.SelectedValue;

            LOGIN_VEHICLE_INFO info_ZC = new LOGIN_VEHICLE_INFO();
            info_ZC.VEHICLEID = strVEHICLEID;
            info_ZC.HPHM = strHPHM;
            info_ZC.CLZL = drpCLZL.SelectedItem.Text;
            info_ZC.CLZLDH = drpCLZL.SelectedItem.Value;
            info_ZC.HPZL = drpHPZL.SelectedItem.Text;
            info_ZC.HPZLDH = strHPZL;
            info_ZC.VIN = strVIN;
            info_ZC.JYLB = drpTestType.SelectedItem.Text;
            info_ZC.JYLBDH = strJYLB;
            info_ZC.FDJH = strFDJHM;
            info_ZC.PP = strPP;
            info_ZC.XH = strXH;
            info_ZC.PPXH = strPP + strXH;
            info_ZC.ZCZWZ = strZCZWZ;
            info_ZC.QZDZ = drpQZDZ.SelectedItem.Text;
            info_ZC.QZDZDH = drpQZDZ.SelectedItem.Value;
            info_ZC.YGGSNFKT = drpYGGSNFKT.SelectedItem.Text;
            info_ZC.YGGSNFKTDH = drpYGGSNFKT.SelectedItem.Value;
            info_ZC.RLLB = drpRLLB.SelectedItem.Text;
            info_ZC.RLLBDH = drpRLLB.SelectedItem.Value;
            info_ZC.CCDJRQ = strCSDJRQ;
            info_ZC.CCRQ = strCSDJRQ;
            info_ZC.ZBZL = strZBZL;
            info_ZC.ZZL = strZZL;
            info_ZC.CYS = strHZRS;
            info_ZC.ZXZXJXS = drpZXZXJXS.SelectedItem.Text;
            info_ZC.ZXZXJXSDH = drpZXZXJXS.SelectedItem.Value;
            info_ZC.ZXZLX = drpZXZLX.SelectedItem.Text;
            info_ZC.ZXZLXDH = drpZXZLX.SelectedItem.Value;
            info_ZC.ZGSJCS = strZGSJCS;
            info_ZC.LJXSLC = strLJXSLC;
            info_ZC.SYR = strSYR;
            info_ZC.LXDZ = strAddress;
            info_ZC.SYXZ = drpSYXZ.SelectedItem.Text;
            info_ZC.SYXZDH = drpSYXZ.SelectedItem.Value;
            info_ZC.HDZH = strHDZZL;
            info_ZC.JYXM_LW = strJYXM;
            info_ZC.JYXM = strJYXM;
            info_ZC.CSC = strWKCCC;
            info_ZC.CSK = strWKCCK;
            info_ZC.CSG = strWKCCG;
            info_ZC.DLY = userInfo.UserName;
            info_ZC.ZZS = drpZZS.SelectedValue;
            info_ZC.QDZWZ = strQDZWZ;
            info_ZC.LWCXWZJLDH = drpLWCXWZJL.SelectedItem.Value;
            info_ZC.LWCXWZJL = drpLWCXWZJL.SelectedItem.Text;
            info_ZC.CCRQ = strCCRQ;
            info_ZC.SFSQCLC = strSFSQCLC;
            info_ZC.GLCHPHM = strHPHMGC;
            info_ZC.GLCHPZLDH = strHPZLGC;
            info_ZC.GLCHPZL = drpHPZLGC.SelectedItem.Text;
            info_ZC.GLCJYXM = strJYXMGC;
            info_ZC.SFSQCLC = chkQCLC.Checked ? "1" : "0";

            LOGIN_VEHICLE_INFO info_GC = new LOGIN_VEHICLE_INFO();
            string strVEHICLEIDGC = strHPZLGC + strHPHMGC;
            info_GC.VEHICLEID = strVEHICLEIDGC;
            info_GC.HPHM = strHPHMGC;
            info_GC.CLZL = drpCLZLGC.SelectedItem.Text;
            info_GC.CLZLDH = drpCLZLGC.SelectedItem.Value;
            info_GC.HPZL = drpHPZLGC.SelectedItem.Text;
            info_GC.HPZLDH = strHPZLGC;
            info_GC.VIN = strVINGC;
            info_GC.JYLB = drpTestTypeGC.SelectedItem.Text;
            info_GC.JYLBDH = strTestTypeGC;
            info_GC.PP = strPPGC;
            info_GC.XH = strXHGC;
            info_GC.PPXH = strPPGC + strXHGC;
            info_GC.ZCZWZ = strZCZWZGC;
            info_GC.CCDJRQ = strCCDJRQGC;
            info_GC.CCRQ = strCCRQGC;
            info_GC.ZBZL = strZBZLGC;
            info_GC.ZZL = strZZLGC;
            info_GC.SYR = strSYRGC;
            info_GC.LXDZ = strAddressGC;
            info_GC.LXDH = strTelGC;
            info_GC.SYXZ = drpSYXZGC.SelectedItem.Text;
            info_GC.SYXZDH = drpSYXZGC.SelectedItem.Value;
            info_GC.HDZH = strHDZZLGC;
            info_GC.JYXM = strJYXMGC;
            info_GC.CSC = strCSCGC;
            info_GC.CSK = strCSKGC;
            info_GC.CSG = strCSGGC;
            info_GC.DLY = userInfo.UserName;
            info_GC.ZZS = drpZZSGC.SelectedValue;
            info_GC.LWCXWZJLDH = drpLWCXGC.SelectedItem.Value;
            info_GC.LWCXWZJL = drpLWCXGC.SelectedItem.Text;
            info_GC.GLCHPHM = strHPHM;
            info_GC.GLCHPZL = drpHPZL.SelectedItem.Text;
            info_GC.GLCHPZLDH = drpHPZL.SelectedItem.Value;
            info_GC.GLCJYXM = strJYXM;


            LOGIN_VEHICLE_INFO_BLL bll = new LOGIN_VEHICLE_INFO_BLL();
            var vRet_Login_ZC = LoginHelper.GetLoginInfo(strHPHM, strHPZL);
            var vRet_Login_GC = LoginHelper.GetLoginInfo(strHPHMGC, strHPZLGC);

            DbFactory factory = new DbFactory();

            if (vRet_Login_ZC != null)
            {
                factory.Add(bll.UpdateSQL(info_ZC, vRet_Login_ZC.ID));
            }
            else
            {
                factory.Add(bll.InsertSQL(info_ZC));
            }

            if (vRet_Login_GC != null)
            {
                factory.Add(bll.UpdateSQL(info_GC, vRet_Login_GC.ID));
            }
            else
            {
                factory.Add(bll.InsertSQL(info_GC));
            }

            if (string.IsNullOrEmpty(userInfo.UserName))
            {
                gfAjaxJs.SetAlertMsg(this.UpdatePanel1, "当前没有授权,请退出系统重新登录！");
                return;
            }

            bool bOnGoing = LoginHelper.GetVehicleStatus(strVEHICLEID);
            if (bOnGoing)
            {
                gfAjaxJs.SetAlertMsg(this.UpdatePanel1, "车辆【" + strVEHICLEID + "】正在检测，不能保存当前信息！");
                return;
            }

            bOnGoing = LoginHelper.GetVehicleStatus(strVEHICLEIDGC);
            if (bOnGoing)
            {
                gfAjaxJs.SetAlertMsg(this.UpdatePanel1, "车辆【" + strVEHICLEIDGC + "】正在检测，不能保存当前信息！");
                return;
            }

            bool bRet = factory.Execute();
            if (bRet)
            {
                hidID.Value = LoginHelper.GetLoginInfo(strHPHM, strHPZL).ID.ToString();
                hidGCID.Value = LoginHelper.GetLoginInfo(strHPHMGC, strHPZLGC).ID.ToString();
                LoginHelper.SavePPXHAndFDJXH(info_ZC);
                LoginHelper.SavePPXHAndFDJXH(info_GC);
                gfAjaxJs.SetAlertMsg(this.UpdatePanel1, "车牌号码【" + strHPHM + "," + strHPHMGC + "】保存成功！");
                btnSendGC.Enabled = true;
                btnSendGC.CssClass = "btnSendEnabled";
            }
            else
            {
                gfAjaxJs.SetAlertMsg(this.UpdatePanel1, "车牌号码【" + strHPHM + "," + strHPHMGC + "】保存失败！");
                return;
            }

            #endregion
        }

        protected void chkJYXMGC_SelectedIndexChanged(object sender, EventArgs e)
        {
            bool bFirstTest = rbtnTestGC.SelectedValue == "0" ? true : false;
            LoginHelper.JYXMChanged(chkJYXMGC, lstItemsGC, bFirstTest);
        }

        protected void btnSearchGC_Click(object sender, EventArgs e)
        {
            string strHPHMGCStart = txtHPHMStartGC.Text.Trim().ToUpper();
            string strHPHM = strHPHMGCStart +  txtHPHMGC.Text.Trim().ToUpper();
            string strVIN = txtVINGC.Text.Trim().ToUpper();
            string strHPZL = drpHPZLGC.SelectedValue;

            if (string.IsNullOrEmpty(strHPHM) && string.IsNullOrEmpty(strVIN))
            {
                gfAjaxJs.SetAlertMsg(this.UpdatePanel1, "请输入号牌号码或者VIN进行查询！");
                return;
            }

            if (!strHPHM.Contains("挂"))
            {
                strHPHM = strHPHM + "挂";
            }

            if (chkSFLW.Checked)
            {
                string strJYJGBH = "xxxx";

                string xtlb = "";//系统类别
                //接口提供者的业务类别代码，默认为“18”（代表机动车检验监管系统）
                string jkxlh = "";//接口序列号
                //由外挂系统请求服务平台授权生成下发
                string jkid = "";//接口标志
                //5位，由系统类别＋C＋两位接口顺序号组成，用于唯一表示一个接口。

                var doc = new XDocument(
                    new XElement("root",
                        new XElement("QueryCondition",
                            new XElement("hphm", strHPHM),
                            new XElement("hpzl", strHPZL),
                            new XElement("clsbdh", strVIN),
                            new XElement("jyjgbh", strJYJGBH)
                            )
                        )
                    );
                string QueryXmlDoc = doc.ToString();
                localhost.myWebService call = new localhost.myWebService();
                string result = call.queryObjectOut(xtlb, jkxlh, jkid, QueryXmlDoc);

                StringReader reader = new StringReader(result);
                XmlDocument xmlDoc = new XmlDocument();
                xmlDoc.Load(reader);
                XmlNode root = xmlDoc.SelectSingleNode("//vehispara");
                if (root != null)
                {
                    LOGIN_VEHICLE_INFO info = new LOGIN_VEHICLE_INFO();

                    info.JYLBDH = root.SelectSingleNode("jylb").InnerText;
                    info.ZYWLBDH = root.SelectSingleNode("ywlx").InnerText;
                    info.HPHM = root.SelectSingleNode("hphm").InnerText;
                    info.HPZLDH = root.SelectSingleNode("hpzl").InnerText;
                    info.VIN = root.SelectSingleNode("clsbdh").InnerText;

                    info.SYR = root.SelectSingleNode("syr").InnerText;
                    info.LXDZ = root.SelectSingleNode("zsxzqh").InnerText;
                    info.SYXZDH = root.SelectSingleNode("syxz").InnerText;
                    info.PP = root.SelectSingleNode("clpp1").InnerText;
                    info.XH = root.SelectSingleNode("clxh").InnerText;
                    info.FDJH = root.SelectSingleNode("fdjh").InnerText;
                    info.CCDJRQ = root.SelectSingleNode("ccdjrq").InnerText;
                    info.CYS = root.SelectSingleNode("hdzk").InnerText;
                    info.ZZL = root.SelectSingleNode("zzl").InnerText;
                    info.ZBZL = root.SelectSingleNode("zbzl").InnerText;
                    info.HDZH = root.SelectSingleNode("hdzzl").InnerText;
                    info.CSC = root.SelectSingleNode("cwkc").InnerText;
                    info.CSG = root.SelectSingleNode("cwkg").InnerText;
                    info.CSK = root.SelectSingleNode("cwkk").InnerText;
                    info.ZXZLXDH = root.SelectSingleNode("zxxs").InnerText;
                    info.ZXZXJXSDH = root.SelectSingleNode("zxzxjxs").InnerText;
                    info.QZDZDH = root.SelectSingleNode("qzdz").InnerText;
                    info.YGGSNFKTDH = root.SelectSingleNode("ygddtz").InnerText;
                    info.ZCZWZ = root.SelectSingleNode("zczw").InnerText;
                    info.QDXSDH = root.SelectSingleNode("qdxs").InnerText;
                    info.JZZZWZ = root.SelectSingleNode("jzzzwz").InnerText;
                    info.RLLBDH = root.SelectSingleNode("rlzl").InnerText;
                    info.ZGSJCS = root.SelectSingleNode("zgsjcs").InnerText;
                    info.LWCXWZJLDH = root.SelectSingleNode("lwcxwzjldh").InnerText;
                    info.ZZS = root.SelectSingleNode("zzs").InnerText;

                    LoadData(info);
                }
                else
                {
                    gfAjaxJs.SetAlertMsg(this.UpdatePanel1, "查询结果为空！");
                }
            }
            else
            {
                LOGIN_VEHICLE_INFO_BLL bll = new LOGIN_VEHICLE_INFO_BLL();
                string strJYLB = drpTestTypeGC.SelectedValue + ",";
                string strSql = "";
                if (!string.IsNullOrEmpty(strHPHM))
                {
                    strSql = "VEHICLEID='" + drpHPZLGC.SelectedValue + strHPHM + "'  and HPZLDH='" + strHPZL + "' order by ID desc";
                }
                else if (!string.IsNullOrEmpty(strVIN))
                {
                    strSql = "VIN='" + strVIN + "'  and HPZLDH='" + strHPZL + "' order by ID desc";
                }

                LOGIN_VEHICLE_INFO[] infos = bll.GetModelList(strSql);

                if (infos.Length == 1)
                {
                    BindQCLC(infos[0].HPHM, infos[0].HPZLDH);
                    hidGCID.Value = infos[0].ID.ToString();
                }
                else if (infos.Length > 1)
                {
                    gfAjaxJs.SetAlertMsg(this.UpdatePanel1, "查询结果大于1条，显示为最近记录！");
                    BindQCLC(infos[0].HPHM, infos[0].HPZLDH);
                    hidGCID.Value = infos[0].ID.ToString();
                }
                else
                {
                    gfAjaxJs.SetAlertMsg(this.UpdatePanel1, "查询结果为空！");
                    ResetAllGC();
                }
            }
        }

        protected void btnSendGC_Click(object sender, EventArgs e)
        {
            bool bIsFirstTest_ZC = rbtnTest.SelectedValue == "0" ? true : false;//是否为初检

            //bool bHasCharge_ZC = LoginHelper.HasCharge(hidID.Value, "A", bIsFirstTest_ZC);
            //if (!bHasCharge_ZC)
            //{
            //    gfAjaxJs.SetAlertMsg(this.UpdatePanel1, "当前车辆没有收费，请收费后在发送！");
            //    return;
            //}

            LoginHelper.ResetAllValidate(GetType(), this);

            var dicCheckItems = LoginHelper.CheckAllInputItems(hidID.Value, hidGCID.Value, "A");
            if (dicCheckItems["A"].Count > 0)
            {
                foreach (var v in dicCheckItems["A"])
                {
                    TextBox txt = (TextBox)this.FindControl(v);
                    txt.BackColor = Color.Yellow;
                }
                return;
            }

            if (dicCheckItems["AG"].Count > 0)
            {
                foreach (var v in dicCheckItems["AG"])
                {
                    TextBox txt = (TextBox)this.FindControl(v);
                    txt.BackColor = Color.Yellow;
                }
                return;
            }

            LOGIN_VEHICLE_INFO_BLL info_bll = new LOGIN_VEHICLE_INFO_BLL();
            var info = info_bll.GetModel(Convert.ToInt32(hidID.Value));
            var infoGC = info_bll.GetModel(Convert.ToInt32(hidGCID.Value));
            if (string.IsNullOrEmpty(info.JYXM))
            {
                gfAjaxJs.SetAlertMsg(this.UpdatePanel1, "请选择主车检验项目保存后，在进行发送！");
                return;
            }

            if (string.IsNullOrEmpty(infoGC.JYXM))
            {
                gfAjaxJs.SetAlertMsg(this.UpdatePanel1, "请选择检验挂车项目保存后，在进行发送！");
                return;
            }

            bool bIsUpdate_ZC;
            VEHICLE_DISPATCH model_ZC = LoginHelper.GetDispathchByLoginID(hidID.Value, "A", bIsFirstTest_ZC, out bIsUpdate_ZC);
            bool bIsFirstTest_GC = rbtnTestGC.SelectedValue == "0" ? true : false;//是否为初检

            bool bIsUpdate_GC;
            VEHICLE_DISPATCH model_GC = LoginHelper.GetDispathchByLoginID(hidGCID.Value, "A", bIsFirstTest_GC, out bIsUpdate_GC);

            model_ZC.GLCJCLSH = model_GC.JCLSH;
            model_ZC.GLCHPHM = model_GC.HPHM;
            model_ZC.GLCHPZL = model_GC.HPZL;
            model_ZC.GLCHPZLDH = model_GC.HPZLDH;
            model_ZC.GLCJYXM = model_GC.JYXM;
            model_ZC.SFSQCLC = "1";

            model_GC.GLCJCLSH = model_ZC.JCLSH;
            model_GC.GLCHPHM = model_ZC.HPHM;
            model_GC.GLCHPZL = model_ZC.HPZL;
            model_GC.GLCHPZLDH = model_ZC.HPZLDH;
            model_GC.GLCJYXM = model_ZC.JYXM;
            model_GC.SFSQCLC = "1"; 

            VEHICLE_DISPATCH_BLL disBll = new VEHICLE_DISPATCH_BLL();

            DbFactory factory = new DbFactory();

            if (bIsUpdate_ZC)
            {
                factory.Add(disBll.UpdateSQL(model_ZC, model_ZC.JCLSH));
            }
            else
            {
                factory.Add(disBll.InsertSQL(model_ZC));
            }
            if (bIsUpdate_GC)
            {
                factory.Add(disBll.UpdateSQL(model_GC, model_GC.JCLSH));
            }
            else
            {
                factory.Add(disBll.InsertSQL(model_GC));
            }

            if (factory.Execute())
            {
                gfAjaxJs.SetAlertMsg(UpdatePanel1, "发送成功！");
                ResetAllGC();
                btnSendGC.CssClass = "btnSendDisabled";
                btnSendGC.Enabled = false;
                LoginedList1.BindList("", "");
                return;
            }
            else
            {
                gfAjaxJs.SetAlertMsg(UpdatePanel1, "发送失败！");
                btnSend.CssClass = "btnSendEnabled";
                btnSend.Enabled = true;
                return;
            }

        }

        /// <summary>
        /// Reset All Controls
        /// </summary>
        private void ResetAllGC()
        {
            ResetAll();
            List<LoginHelper.ControlNames> lstCtl = new List<LoginHelper.ControlNames>();
            List<Control> lstControls = new List<Control>();

            lstCtl.Add(new LoginHelper.ControlNames(drpTestTypeGC.ID,""));
            lstControls.Add(drpTestTypeGC);

            lstCtl.Add(new LoginHelper.ControlNames(txtAJLSHGC.ID, ""));
            lstControls.Add(txtAJLSHGC);

            lstCtl.Add(new LoginHelper.ControlNames(txtHPHMGC.ID, ""));
            lstControls.Add(txtHPHMGC);

            lstCtl.Add(new LoginHelper.ControlNames(drpHPZLGC.ID, ""));
            lstControls.Add(drpHPZLGC);

            lstCtl.Add(new LoginHelper.ControlNames(chkZCZWZGC.ID, ""));
            lstControls.Add(chkZCZWZGC);

            lstCtl.Add(new LoginHelper.ControlNames(txtVINGC.ID, ""));
            lstControls.Add(txtVINGC);

            lstCtl.Add(new LoginHelper.ControlNames(drpCLZLGC.ID, ""));
            lstControls.Add(drpCLZLGC);

            lstCtl.Add(new LoginHelper.ControlNames(txtSYRGC.ID, ""));
            lstControls.Add(txtSYRGC);

            lstCtl.Add(new LoginHelper.ControlNames(txtAddressGC.ID, ""));
            lstControls.Add(txtAddressGC);

            lstCtl.Add(new LoginHelper.ControlNames(txtTelGC.ID, ""));
            lstControls.Add(txtTelGC);

            lstCtl.Add(new LoginHelper.ControlNames(drpSYXZGC.ID, ""));
            lstControls.Add(drpSYXZGC);

            lstCtl.Add(new LoginHelper.ControlNames(txtPPGC.ID, ""));
            lstControls.Add(txtPPGC);

            lstCtl.Add(new LoginHelper.ControlNames(txtXHGC.ID, ""));
            lstControls.Add(txtXHGC);

            lstCtl.Add(new LoginHelper.ControlNames(txtCCRQGC.ID, DateTime.Now.AddYears(-5).ToString("yyyy-MM-dd")));
            lstControls.Add(txtCCRQGC);

            lstCtl.Add(new LoginHelper.ControlNames(txtCCDJRQGC.ID, DateTime.Now.AddYears(-5).ToString("yyyy-MM-dd")));
            lstControls.Add(txtCCDJRQGC);

            lstCtl.Add(new LoginHelper.ControlNames(txtZZLGC.ID, ""));
            lstControls.Add(txtZZLGC);

            lstCtl.Add(new LoginHelper.ControlNames(txtZBZLGC.ID, ""));
            lstControls.Add(txtZBZLGC);

            lstCtl.Add(new LoginHelper.ControlNames(txtHDZZLGC.ID, ""));
            lstControls.Add(txtHDZZLGC);

            lstCtl.Add(new LoginHelper.ControlNames(txtCSCGC.ID, ""));
            lstControls.Add(txtCSCGC);

            lstCtl.Add(new LoginHelper.ControlNames(txtCSKGC.ID, ""));
            lstControls.Add(txtCSKGC);

            lstCtl.Add(new LoginHelper.ControlNames(txtCSGGC.ID, ""));
            lstControls.Add(txtCSGGC);

            lstCtl.Add(new LoginHelper.ControlNames(drpLWCXGC.ID, ""));
            lstControls.Add(drpLWCXGC);

            LoginHelper.ResetAllControls(lstCtl, lstControls);

            drpZZSGC_SelectedIndexChanged(null, null);
            lstItemsGC.All(x => x.Selected = false);

            for (int i = 0; i < chkJYXMGC.Items.Count; i++)
            {
                chkJYXMGC.Items[i].Selected = false;
            }

            btnSaveGC.Enabled = true;
            btnSaveGC.CssClass = "btnSaveEnabled";

            LoginHelper.ResetAllValidate(GetType(), this);
        }

        protected void btnResetGC_Click(object sender, EventArgs e)
        {
            ResetAllGC();
        }

        protected void chkAllGC_CheckedChanged(object sender, EventArgs e)
        {
            LoginHelper.CheckAll(chkJYXMGC, chkAllGC.Checked);
        }

        protected void btnSearchPPXH_Click(object sender, EventArgs e)
        {
            string strPP = txtPP.Text.Trim();
            string strXH = txtXH.Text.Trim().ToUpper();
            TYPE_CX_CONTENT_BLL bll = new TYPE_CX_CONTENT_BLL();
            TYPE_CX_CONTENT[] m_TYPE_CX_CONTENT = bll.GetModelList("PP='" + strPP + "' and XH='" + strXH + "' order by ID desc");

            if (m_TYPE_CX_CONTENT.Length > 0)
            {
                TYPE_CX_CONTENT vContent = m_TYPE_CX_CONTENT[0];

                if (!string.IsNullOrEmpty(vContent.ZZS))
                {
                    drpZZS.SelectedValue = vContent.ZZS;
                    drpZZS_SelectedIndexChanged(null, null);
                }

                List<LoginHelper.ControlNames> lstCtl = new List<LoginHelper.ControlNames>();
                List<Control> lstControls = new List<Control>();

                lstCtl.Add(new LoginHelper.ControlNames(drpQZDZ.ID.ToString(), "QZDZ"));
                lstControls.Add(drpQZDZ);

                lstCtl.Add(new LoginHelper.ControlNames(drpRLLB.ID.ToString(), "RLLB"));
                lstControls.Add(drpRLLB);

                lstCtl.Add(new LoginHelper.ControlNames(chkZCZWZ.ID.ToString(), "ZCZWZ"));
                lstControls.Add(chkZCZWZ);

                lstCtl.Add(new LoginHelper.ControlNames(chkQDZWZ.ID.ToString(), "QDZWZ"));
                lstControls.Add(chkQDZWZ);

                lstCtl.Add(new LoginHelper.ControlNames(drpZXZLX.ID.ToString(), "ZXZLX"));
                lstControls.Add(drpZXZLX);

                lstCtl.Add(new LoginHelper.ControlNames(drpZXZXJXS.ID.ToString(), "ZXZXJXS"));
                lstControls.Add(drpZXZXJXS);

                lstCtl.Add(new LoginHelper.ControlNames(drpCLZL.ID.ToString(), "CLZL"));
                lstControls.Add(drpCLZL);

                lstCtl.Add(new LoginHelper.ControlNames(txtHDZZL.ID.ToString(), "HDZH"));
                lstControls.Add(txtHDZZL);

                lstCtl.Add(new LoginHelper.ControlNames(txtHZRS.ID.ToString(), "CYS"));
                lstControls.Add(txtHZRS);

                lstCtl.Add(new LoginHelper.ControlNames(txtWKCCC.ID.ToString(), "CSC"));
                lstControls.Add(txtWKCCC);

                lstCtl.Add(new LoginHelper.ControlNames(txtWKCCG.ID.ToString(), "CSG"));
                lstControls.Add(txtWKCCG);

                lstCtl.Add(new LoginHelper.ControlNames(txtWKCCK.ID.ToString(), "CSK"));
                lstControls.Add(txtWKCCK);

                lstCtl.Add(new LoginHelper.ControlNames(txtZBZL.ID.ToString(), "ZBZL"));
                lstControls.Add(txtZBZL);

                lstCtl.Add(new LoginHelper.ControlNames(txtZGSJCS.ID.ToString(), "ZGSJCS"));
                lstControls.Add(txtZGSJCS);

                lstCtl.Add(new LoginHelper.ControlNames(txtZZL.ID.ToString(), "ZZL"));
                lstControls.Add(txtZZL);

                LoginHelper.GetPPXH(vContent, lstCtl, lstControls);

                drpQZDZ_SelectedIndexChanged(null, null);
            }
        }

        protected void lbtnCLZL_K_Click(object sender, EventArgs e)
        {
            //HPZL,CLZL,SYXZ,ZXZLX,ZXZXJXS,RYLL
            string[] strXX = new string[] { "01", "K11", "Y12", "1", "1", "B" };
            try
            {
                GetDefalutByCLLX(strXX);
            }
            catch (Exception ex)
            {

            }
        }

        protected void lbtnCLZL_H_Click(object sender, EventArgs e)
        {           
            //HPZL,CLZL,SYXZ,ZXZLX,ZXZXJXS,RYLL
            string[] strXX = new string[] { "01", "H11", "Y18", "1", "1", "B" };
            try
            {
                GetDefalutByCLLX(strXX);
            }
            catch (Exception ex)
            {

            }

        }

        protected void btnSearchGCPPXH_Click(object sender, EventArgs e)
        {
            string strPPGC = txtPPGC.Text.Trim();
            string strXHGC = txtXHGC.Text.Trim().ToUpper();
            TYPE_CX_CONTENT_BLL bll = new TYPE_CX_CONTENT_BLL();
            TYPE_CX_CONTENT[] m_TYPE_CX_CONTENT = bll.GetModelList("PP='" + strPPGC + "' and XH='" + strXHGC + "' order by ID desc");

            if (m_TYPE_CX_CONTENT.Length > 0)
            {
                TYPE_CX_CONTENT vContent = m_TYPE_CX_CONTENT[0];

                if (!string.IsNullOrEmpty(vContent.ZZS))
                {
                    drpZZSGC.SelectedValue = vContent.ZZS;
                    drpZZSGC_SelectedIndexChanged(null, null);
                }

                List<LoginHelper.ControlNames> lstCtl = new List<LoginHelper.ControlNames>();
                List<Control> lstControls = new List<Control>();

                lstCtl.Add(new LoginHelper.ControlNames(chkZCZWZGC.ID.ToString(), "ZCZWZ"));
                lstControls.Add(chkZCZWZGC);

                lstCtl.Add(new LoginHelper.ControlNames(drpCLZLGC.ID.ToString(), "CLZL"));
                lstControls.Add(drpCLZLGC);

                lstCtl.Add(new LoginHelper.ControlNames(txtZZLGC.ID.ToString(), "ZZL"));
                lstControls.Add(txtZZLGC);

                lstCtl.Add(new LoginHelper.ControlNames(txtZBZLGC.ID.ToString(), "ZBZL"));
                lstControls.Add(txtZBZLGC);

                lstCtl.Add(new LoginHelper.ControlNames(txtHDZZLGC.ID.ToString(), "HDZH"));
                lstControls.Add(txtHDZZLGC);

                lstCtl.Add(new LoginHelper.ControlNames(txtCSCGC.ID.ToString(), "CSC"));
                lstControls.Add(txtCSCGC);

                lstCtl.Add(new LoginHelper.ControlNames(txtCSKGC.ID.ToString(), "CSK"));
                lstControls.Add(txtCSKGC);

                lstCtl.Add(new LoginHelper.ControlNames(txtCSGGC.ID.ToString(), "CSG"));
                lstControls.Add(txtCSGGC);

                LoginHelper.GetPPXH(vContent, lstCtl, lstControls);
            }
        }

        protected void lbtnLoginedShow_Click(object sender, EventArgs e)
        {
            if (divLoginList.Visible == false)
            {
                lbtnLoginedShow.Text = "收 起︽";
                divLoginList.Visible = true;
            }
            else
            {
                lbtnLoginedShow.Text = "展 开︾";
                divLoginList.Visible = false;
            }
        }

        protected void lbtnCLZL_X_Click(object sender, EventArgs e)
        {
            //HPZL,CLZL,SYXZ,ZXZLX,ZXZXJXS,RYLL
            string[] strXX = new string[] { "02", "F01", "Y12", "1", "0", "A" };
            try
            {
                GetDefalutByCLLX(strXX);
            }
            catch (Exception ex)
            {

            }
        }

        private void GetDefalutByCLLX(string[] strLst)
        {
            List<LoginHelper.ControlNames> lstCtl = new List<LoginHelper.ControlNames>();
            List<Control> lstControls = new List<Control>();

            lstCtl.Add(new LoginHelper.ControlNames(drpHPZL.ID, strLst[0]));
            lstControls.Add(drpHPZL);

            lstCtl.Add(new LoginHelper.ControlNames(drpCLZL.ID, strLst[1]));
            lstControls.Add(drpCLZL);

            lstCtl.Add(new LoginHelper.ControlNames(drpSYXZ.ID, strLst[2]));
            lstControls.Add(drpSYXZ);

            lstCtl.Add(new LoginHelper.ControlNames(drpZXZLX.ID, strLst[3]));
            lstControls.Add(drpZXZLX);

            lstCtl.Add(new LoginHelper.ControlNames(drpZXZXJXS.ID, strLst[4]));
            lstControls.Add(drpZXZXJXS);

            lstCtl.Add(new LoginHelper.ControlNames(drpRLLB.ID, strLst[5]));
            lstControls.Add(drpRLLB);

            LoginHelper.ResetAllControls(lstCtl, lstControls);
        }

        protected void lbtnCLZL_Q_Click(object sender, EventArgs e)
        {
            //HPZL,CLZL,SYXZ,ZXZLX,ZXZXJXS,RYLL
            string[] strXX = new string[] { "02", "Q11", "Y18", "1", "1", "B" };
            try
            {
                GetDefalutByCLLX(strXX);
            }
            catch (Exception ex)
            {

            }
        }

        protected void rbtnTemplate_SelectedIndexChanged(object sender, EventArgs e)
        {
            LoginHelper.BindTemplate("A", rbtnTemplate, chkJYXM, lstItems);
        }
    }
}